Codegen -1 and -0.0 more efficiently. This implements CodeGen/X86/negatize_zero.ll

llvm-svn: 19313
This commit is contained in:
Chris Lattner 2005-01-06 21:19:16 +00:00
parent 9eef99ef43
commit ae15482076
1 changed files with 9 additions and 2 deletions

View File

@ -560,8 +560,15 @@ void X86ISel::copyConstantToRegister(MachineBasicBlock *MBB,
BuildMI(*MBB, IP, X86::FLD0, 0, R);
else if (CFP->isExactlyValue(+1.0))
BuildMI(*MBB, IP, X86::FLD1, 0, R);
else { // FIXME: PI, other native values
// FIXME: Could handle -1.0 with FLD1/FCHS
else if (CFP->isExactlyValue(-0.0)) {
unsigned Tmp = makeAnotherReg(Type::DoubleTy);
BuildMI(*MBB, IP, X86::FLD0, 0, Tmp);
BuildMI(*MBB, IP, X86::FCHS, 1, R).addReg(Tmp);
} else if (CFP->isExactlyValue(-1.0)) {
unsigned Tmp = makeAnotherReg(Type::DoubleTy);
BuildMI(*MBB, IP, X86::FLD1, 0, Tmp);
BuildMI(*MBB, IP, X86::FCHS, 1, R).addReg(Tmp);
} else { // FIXME: PI, other native values
// FIXME: 2*PI -> LDPI + FADD
// Otherwise we need to spill the constant to memory.