[llvm-commits] [llvm] r46054 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/fp-stack-retcopy.ll

Chris Lattner sabre at nondot.org
Tue Jan 15 21:56:59 PST 2008


Author: lattner
Date: Tue Jan 15 23:56:59 2008
New Revision: 46054

URL: http://llvm.org/viewvc/llvm-project?rev=46054&view=rev
Log:
My previous commit had an incomplete message, it should have been:

make the 'fp return in ST(0)' optimization smart enough to
look through token factor nodes.  THis allows us to compile 
testcases like CodeGen/X86/fp-stack-retcopy.ll into:

_carg:
	subl	$12, %esp
	call	L_foo$stub
	fstpl	(%esp)
	fldl	(%esp)
	addl	$12, %esp
	ret

instead of:

_carg:
	subl	$28, %esp
	call	L_foo$stub
	fstpl	16(%esp)
	movsd	16(%esp), %xmm0
	movsd	%xmm0, 8(%esp)
	fldl	8(%esp)
	addl	$28, %esp
	ret

Still not optimal, but much better and this is a trivial patch.  Fixing 
the rest requires invasive surgery that is is not llvm 2.2 material.


Added:
    llvm/trunk/test/CodeGen/X86/fp-stack-retcopy.ll
Modified:
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

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

==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Jan 15 23:56:59 2008
@@ -767,7 +767,7 @@
       // If this is a load into a scalarsse value, don't store the loaded value
       // back to the stack, only to reload it: just replace the scalar-sse load.
       if (ISD::isNON_EXTLoad(Value.Val) &&
-          Chain.reachesChainWithoutSideEffects(Value.getOperand(0))) {
+           Chain.reachesChainWithoutSideEffects(Value.getOperand(0))) {
         Chain  = Value.getOperand(0);
         MemLoc = Value.getOperand(1);
       } else {

Added: llvm/trunk/test/CodeGen/X86/fp-stack-retcopy.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fp-stack-retcopy.ll?rev=46054&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/X86/fp-stack-retcopy.ll (added)
+++ llvm/trunk/test/CodeGen/X86/fp-stack-retcopy.ll Tue Jan 15 23:56:59 2008
@@ -0,0 +1,12 @@
+; This should not copy the result of foo into an xmm register.
+; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah -mtriple=i686-apple-darwin9 | not grep xmm
+; rdar://5689903
+
+declare double @foo()
+
+define double @carg({ double, double }* byval  %z) nounwind  {
+entry:
+	%tmp5 = tail call double @foo() nounwind 		; <double> [#uses=1]
+	ret double %tmp5
+}
+





More information about the llvm-commits mailing list