Codegen -0.0 correctly. Do not use fldz! This is another -0.0 == +0.0 problem,...
authorChris Lattner <sabre@nondot.org>
Mon, 2 Feb 2004 18:56:30 +0000 (18:56 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 2 Feb 2004 18:56:30 +0000 (18:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11070 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/InstSelectSimple.cpp
lib/Target/X86/X86ISelSimple.cpp

index 5135385ddffa777c77ef4d681569e4f9733a86c6..fd4c44f99e0eb2874c24027eed1e7ddae1e727b8 100644 (file)
@@ -438,10 +438,9 @@ void ISel::copyConstantToRegister(MachineBasicBlock *MBB,
       BMI(MBB, IP, IntegralOpcodeTab[Class], 1, R).addZImm(CI->getRawValue());
     }
   } else if (ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
-    double Value = CFP->getValue();
-    if (Value == +0.0)
+    if (CFP->isExactlyValue(+0.0))
       BMI(MBB, IP, X86::FLD0, 0, R);
-    else if (Value == +1.0)
+    else if (CFP->isExactlyValue(+1.0))
       BMI(MBB, IP, X86::FLD1, 0, R);
     else {
       // Otherwise we need to spill the constant to memory...
@@ -1212,7 +1211,7 @@ void ISel::emitSimpleBinaryOperation(MachineBasicBlock *MBB,
 
   // sub 0, X -> neg X
   if (OperatorClass == 1 && Class != cLong)
-    if (ConstantInt *CI = dyn_cast<ConstantInt>(Op0))
+    if (ConstantInt *CI = dyn_cast<ConstantInt>(Op0)) {
       if (CI->isNullValue()) {
         unsigned op1Reg = getReg(Op1, MBB, IP);
         switch (Class) {
@@ -1228,6 +1227,7 @@ void ISel::emitSimpleBinaryOperation(MachineBasicBlock *MBB,
           return;
         }
       }
+    }
 
   if (!isa<ConstantInt>(Op1) || Class == cLong) {
     static const unsigned OpcodeTab[][4] = {
index 5135385ddffa777c77ef4d681569e4f9733a86c6..fd4c44f99e0eb2874c24027eed1e7ddae1e727b8 100644 (file)
@@ -438,10 +438,9 @@ void ISel::copyConstantToRegister(MachineBasicBlock *MBB,
       BMI(MBB, IP, IntegralOpcodeTab[Class], 1, R).addZImm(CI->getRawValue());
     }
   } else if (ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
-    double Value = CFP->getValue();
-    if (Value == +0.0)
+    if (CFP->isExactlyValue(+0.0))
       BMI(MBB, IP, X86::FLD0, 0, R);
-    else if (Value == +1.0)
+    else if (CFP->isExactlyValue(+1.0))
       BMI(MBB, IP, X86::FLD1, 0, R);
     else {
       // Otherwise we need to spill the constant to memory...
@@ -1212,7 +1211,7 @@ void ISel::emitSimpleBinaryOperation(MachineBasicBlock *MBB,
 
   // sub 0, X -> neg X
   if (OperatorClass == 1 && Class != cLong)
-    if (ConstantInt *CI = dyn_cast<ConstantInt>(Op0))
+    if (ConstantInt *CI = dyn_cast<ConstantInt>(Op0)) {
       if (CI->isNullValue()) {
         unsigned op1Reg = getReg(Op1, MBB, IP);
         switch (Class) {
@@ -1228,6 +1227,7 @@ void ISel::emitSimpleBinaryOperation(MachineBasicBlock *MBB,
           return;
         }
       }
+    }
 
   if (!isa<ConstantInt>(Op1) || Class == cLong) {
     static const unsigned OpcodeTab[][4] = {