Skip to content

Commit 75dbd2c

Browse files
committed
Fix x86 MOVSS lifting to zero-extend the memory-source form (Fix #4030)
1 parent 585943a commit 75dbd2c

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

arch/x86/il.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2573,10 +2573,26 @@ bool GetLowLevelILForInstruction(Architecture* arch, const uint64_t addr, LowLev
25732573
break;
25742574
}
25752575

2576-
// despite MOVSS and VMOVSS both move floating point values,
2577-
// the move is the same as an ordinary move
25782576
case XED_ICLASS_MOVSS:
2579-
il.AddInstruction(WriteILOperand(il, xedd, addr, 0, 0, ReadILOperand(il, xedd, addr, 1, 1)));
2577+
if (xed_operand_is_register(opTwo_name))
2578+
{
2579+
// movss xmm, xmm / movss mem, xmm
2580+
// low 32 bits of dst equals low 32 bits of src xmm reg;
2581+
// for an xmm dst the upper bits are left unchanged
2582+
il.AddInstruction(
2583+
WriteILOperand(il, xedd, addr, 0, 0,
2584+
il.LowPart(4, il.Register(16, regTwo))));
2585+
}
2586+
else // movss xmm, m32
2587+
{
2588+
// low 32 bits of dst xmm reg equals the 32-bit load;
2589+
// the high bits are zeroed
2590+
il.AddInstruction(
2591+
WriteILOperand(il, xedd, addr, 0, 0,
2592+
il.ZeroExtend(16,
2593+
il.Load(4,
2594+
GetILOperandMemoryAddress(il, xedd, addr, 1, 1)))));
2595+
}
25802596
break;
25812597

25822598
case XED_ICLASS_VMOVSS:

0 commit comments

Comments
 (0)