[x64] Load int32 constants with movl instead of movq to avoid sign extension.

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/1867293002

Cr-Commit-Position: refs/heads/master@{#35352}
This commit is contained in:
ahaas 2016-04-08 04:44:46 -07:00 committed by Commit bot
parent d1ec440f5d
commit f7aa8cc70e
2 changed files with 13 additions and 3 deletions

View File

@ -2077,10 +2077,16 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
Register dst = destination->IsRegister() ? g.ToRegister(destination)
: kScratchRegister;
switch (src.type()) {
case Constant::kInt32:
case Constant::kInt32: {
// TODO(dcarney): don't need scratch in this case.
__ Set(dst, src.ToInt32());
int32_t value = src.ToInt32();
if (value == 0) {
__ xorl(dst, dst);
} else {
__ movl(dst, Immediate(value));
}
break;
}
case Constant::kInt64:
__ Set(dst, src.ToInt64());
break;

View File

@ -1774,7 +1774,6 @@ TEST(RunInt32SubP) {
}
}
TEST(RunInt32SubImm) {
{
FOR_UINT32_INPUTS(i) {
@ -1798,6 +1797,11 @@ TEST(RunInt32SubImm) {
}
}
TEST(RunInt32SubImm2) {
BufferedRawMachineAssemblerTester<int32_t> r;
r.Return(r.Int32Sub(r.Int32Constant(-1), r.Int32Constant(0)));
CHECK_EQ(-1, r.Call());
}
TEST(RunInt32SubAndWord32SarP) {
{