[llvm-commits] [llvm] r73850 - in /llvm/trunk: lib/Target/X86/X86FloatingPoint.cpp test/CodeGen/X86/inline-asm-fpstack2.ll

Rafael Espindola rafael.espindola at gmail.com
Sun Jun 21 05:02:56 PDT 2009


Author: rafael
Date: Sun Jun 21 07:02:51 2009
New Revision: 73850

URL: http://llvm.org/viewvc/llvm-project?rev=73850&view=rev
Log:
Fix PR4185.
Handle FpSET_ST0_80 being used when ST0 is still alive.


Added:
    llvm/trunk/test/CodeGen/X86/inline-asm-fpstack2.ll
Modified:
    llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp

Modified: llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp?rev=73850&r1=73849&r2=73850&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp Sun Jun 21 07:02:51 2009
@@ -991,8 +991,13 @@
   case X86::FpSET_ST0_32:
   case X86::FpSET_ST0_64:
   case X86::FpSET_ST0_80:
-    assert((StackTop == 1 || StackTop == 2)
-           && "Stack should have one or two element on it to return!");
+    // FpSET_ST0_80 is generated by copyRegToReg for both function return
+    // and inline assembly with the "st" constrain. In the latter case,
+    // it is possible for FP0 to be alive after this instruction.
+    if (!MI->killsRegister(X86::FP0)) {
+      // Duplicate ST0
+      duplicateToTop(0, 0, I);
+    }
     --StackTop;   // "Forget" we have something on the top of stack!
     break;
   case X86::FpSET_ST1_32:

Added: llvm/trunk/test/CodeGen/X86/inline-asm-fpstack2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/inline-asm-fpstack2.ll?rev=73850&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/X86/inline-asm-fpstack2.ll (added)
+++ llvm/trunk/test/CodeGen/X86/inline-asm-fpstack2.ll Sun Jun 21 07:02:51 2009
@@ -0,0 +1,10 @@
+; RUN: llvm-as < %s | llc -march=x86 > %t
+; RUN: grep {fld	%%st(0)} %t
+; PR4185
+
+define void @test() {
+return:
+	call void asm sideeffect "fistpl $0", "{st}"(double 1.000000e+06)
+	call void asm sideeffect "fistpl $0", "{st}"(double 1.000000e+06)
+	ret void
+}





More information about the llvm-commits mailing list