Subzero: Build a better bitcast. The x86 lowering of bitcast between integers and floats forced the transfer through a stack slot (the original implementer *cough* *cough* wasn't aware of the movd instruction). This requires excess instructions, but also a store to memory followed immediately by a load from that location is very slow. This fixes the problem by using the movd instruction instead. BUG= none R=jpp@chromium.org Review URL: https://codereview.chromium.org/2077503002 .
diff --git a/src/IceTargetLoweringX86BaseImpl.h b/src/IceTargetLoweringX86BaseImpl.h index b28c009..3ed27cb 100644 --- a/src/IceTargetLoweringX86BaseImpl.h +++ b/src/IceTargetLoweringX86BaseImpl.h
@@ -3059,24 +3059,10 @@ } break; case IceType_i32: case IceType_f32: { - Operand *Src0RM = legalize(Src0, Legal_Reg | Legal_Mem); - Type SrcType = Src0RM->getType(); - assert((DestTy == IceType_i32 && SrcType == IceType_f32) || - (DestTy == IceType_f32 && SrcType == IceType_i32)); - // a.i32 = bitcast b.f32 ==> - // t.f32 = b.f32 - // s.f32 = spill t.f32 - // a.i32 = s.f32 - Variable *T = nullptr; - // TODO: Should be able to force a spill setup by calling legalize() with - // Legal_Mem and not Legal_Reg or Legal_Imm. - SpillVariable *SpillVar = Func->makeVariable<SpillVariable>(SrcType); - SpillVar->setLinkedTo(Dest); - Variable *Spill = SpillVar; - Spill->setMustNotHaveReg(); - _mov(T, Src0RM); - _mov(Spill, T); - _mov(Dest, Spill); + Variable *Src0R = legalizeToReg(Src0); + Variable *T = makeReg(DestTy); + _movd(T, Src0R); + _mov(Dest, T); } break; case IceType_i64: { assert(Src0->getType() == IceType_f64);
diff --git a/tests_lit/llvm2ice_tests/bitcast.ll b/tests_lit/llvm2ice_tests/bitcast.ll index b5e9066..399d3fe 100644 --- a/tests_lit/llvm2ice_tests/bitcast.ll +++ b/tests_lit/llvm2ice_tests/bitcast.ll
@@ -19,7 +19,7 @@ ret i32 %v0 } ; CHECK-LABEL: cast_f2i -; CHECK: mov eax +; CHECK: movd eax ; ARM32-LABEL: cast_f2i ; ARM32: vmov r{{[0-9]+}}, s{{[0-9]+}}