This is the real fix for Codegen/X86/2004-04-13-FPCMOV-Crash.llx which works
authorChris Lattner <sabre@nondot.org>
Wed, 14 Apr 2004 02:42:32 +0000 (02:42 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 14 Apr 2004 02:42:32 +0000 (02:42 +0000)
even when the "optimization" I added before is turned off.  It generates this
extremely pointless code:

test:
        fld QWORD PTR [%ESP + 4]
        mov %AL, 0
        test %AL, %AL
        fcmove %ST(0), %ST(0)
        ret

Good thing the optimizer will have removed this before code generation
anyway.  :)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12939 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/FloatingPoint.cpp
lib/Target/X86/X86FloatingPoint.cpp

index 70a643b254dc0f0d993de2bdd279c53ee66d7834..e47554b57b4bfb07ed22def8458d1a53c65fefcb 100644 (file)
@@ -682,13 +682,14 @@ void FPS::handleCondMovFP(MachineBasicBlock::iterator &I) {
   MI->getOperand(0).setReg(getSTReg(Op1));
 
   // If we kill the second operand, make sure to pop it from the stack.
-  for (LiveVariables::killed_iterator KI = LV->killed_begin(MI),
-        E = LV->killed_end(MI); KI != E; ++KI)
-    if (KI->second == X86::FP0+Op1) {
-      // Get this value off of the register stack.
-      freeStackSlotAfter(I, Op1);
-      break;
-    }
+  if (Op0 != Op1) 
+    for (LiveVariables::killed_iterator KI = LV->killed_begin(MI),
+           E = LV->killed_end(MI); KI != E; ++KI)
+      if (KI->second == X86::FP0+Op1) {
+        // Get this value off of the register stack.
+        freeStackSlotAfter(I, Op1);
+        break;
+      }
 }
 
 
index 70a643b254dc0f0d993de2bdd279c53ee66d7834..e47554b57b4bfb07ed22def8458d1a53c65fefcb 100644 (file)
@@ -682,13 +682,14 @@ void FPS::handleCondMovFP(MachineBasicBlock::iterator &I) {
   MI->getOperand(0).setReg(getSTReg(Op1));
 
   // If we kill the second operand, make sure to pop it from the stack.
-  for (LiveVariables::killed_iterator KI = LV->killed_begin(MI),
-        E = LV->killed_end(MI); KI != E; ++KI)
-    if (KI->second == X86::FP0+Op1) {
-      // Get this value off of the register stack.
-      freeStackSlotAfter(I, Op1);
-      break;
-    }
+  if (Op0 != Op1) 
+    for (LiveVariables::killed_iterator KI = LV->killed_begin(MI),
+           E = LV->killed_end(MI); KI != E; ++KI)
+      if (KI->second == X86::FP0+Op1) {
+        // Get this value off of the register stack.
+        freeStackSlotAfter(I, Op1);
+        break;
+      }
 }