aboutsummaryrefslogtreecommitdiff
path: root/lib/Target
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-06 21:19:16 +0000
committerChris Lattner <sabre@nondot.org>2005-01-06 21:19:16 +0000
commit6ac95f967930ad9bad38363f8b79efb67bc1d58c (patch)
tree742ee140c4205ebfc79fb8a650da35f7584030bf /lib/Target
parent7c8ad7aa41fe65742b071e2172a34db89d417aba (diff)
Codegen -1 and -0.0 more efficiently. This implements CodeGen/X86/negatize_zero.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19313 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/X86/X86ISelSimple.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Target/X86/X86ISelSimple.cpp b/lib/Target/X86/X86ISelSimple.cpp
index 5e6fd2fbd2..4aeab3e518 100644
--- a/lib/Target/X86/X86ISelSimple.cpp
+++ b/lib/Target/X86/X86ISelSimple.cpp
@@ -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.