Generate ftst instructions for comparison against zero
authorChris Lattner <sabre@nondot.org>
Tue, 3 Feb 2004 18:54:04 +0000 (18:54 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 3 Feb 2004 18:54:04 +0000 (18:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11098 91177308-0d34-0410-b5e6-96231b3b80d8

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

index abfcad15668e42f6783f90f84029abcae4fe234b..45df82906bcc2f788d95b5640c4f2588af8104b7 100644 (file)
@@ -702,6 +702,15 @@ unsigned ISel::EmitComparison(unsigned OpNum, Value *Op0, Value *Op1,
       return OpNum;
     }
 
+  // Special case handling of comparison against +/- 0.0
+  if (ConstantFP *CFP = dyn_cast<ConstantFP>(Op1))
+    if (CFP->isExactlyValue(+0.0) || CFP->isExactlyValue(-0.0)) {
+      BMI(MBB, IP, X86::FTST, 1).addReg(Op0r);
+      BMI(MBB, IP, X86::FNSTSWr8, 0);
+      BMI(MBB, IP, X86::SAHF, 1);
+      return OpNum;
+    }
+
   unsigned Op1r = getReg(Op1, MBB, IP);
   switch (Class) {
   default: assert(0 && "Unknown type class!");
index abfcad15668e42f6783f90f84029abcae4fe234b..45df82906bcc2f788d95b5640c4f2588af8104b7 100644 (file)
@@ -702,6 +702,15 @@ unsigned ISel::EmitComparison(unsigned OpNum, Value *Op0, Value *Op1,
       return OpNum;
     }
 
+  // Special case handling of comparison against +/- 0.0
+  if (ConstantFP *CFP = dyn_cast<ConstantFP>(Op1))
+    if (CFP->isExactlyValue(+0.0) || CFP->isExactlyValue(-0.0)) {
+      BMI(MBB, IP, X86::FTST, 1).addReg(Op0r);
+      BMI(MBB, IP, X86::FNSTSWr8, 0);
+      BMI(MBB, IP, X86::SAHF, 1);
+      return OpNum;
+    }
+
   unsigned Op1r = getReg(Op1, MBB, IP);
   switch (Class) {
   default: assert(0 && "Unknown type class!");