[llvm-branch-commits] [llvm-branch] r92895 - in /llvm/branches/Apple/Zoidberg: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/and-su.ll test/CodeGen/X86/test-nofold.ll

Evan Cheng evan.cheng at apple.com
Wed Jan 6 18:04:27 PST 2010


Author: evancheng
Date: Wed Jan  6 20:04:27 2010
New Revision: 92895

URL: http://llvm.org/viewvc/llvm-project?rev=92895&view=rev
Log:
Merge 92885.

Modified:
    llvm/branches/Apple/Zoidberg/lib/Target/X86/X86ISelLowering.cpp
    llvm/branches/Apple/Zoidberg/test/CodeGen/X86/and-su.ll
    llvm/branches/Apple/Zoidberg/test/CodeGen/X86/test-nofold.ll

Modified: llvm/branches/Apple/Zoidberg/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/X86/X86ISelLowering.cpp?rev=92895&r1=92894&r2=92895&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/X86/X86ISelLowering.cpp Wed Jan  6 20:04:27 2010
@@ -5612,13 +5612,21 @@
       // because a TEST instruction will be better.
       bool NonFlagUse = false;
       for (SDNode::use_iterator UI = Op.getNode()->use_begin(),
-           UE = Op.getNode()->use_end(); UI != UE; ++UI)
-        if (UI->getOpcode() != ISD::BRCOND &&
-            UI->getOpcode() != ISD::SELECT &&
-            UI->getOpcode() != ISD::SETCC) {
+             UE = Op.getNode()->use_end(); UI != UE; ++UI) {
+        SDNode *User = *UI;
+        unsigned UOpNo = UI.getOperandNo();
+        if (User->getOpcode() == ISD::TRUNCATE && User->hasOneUse()) {
+          // Look pass truncate.
+          UOpNo = User->use_begin().getOperandNo();
+          User = *User->use_begin();
+        }
+        if (User->getOpcode() != ISD::BRCOND &&
+            User->getOpcode() != ISD::SETCC &&
+            (User->getOpcode() != ISD::SELECT || UOpNo != 0)) {
           NonFlagUse = true;
           break;
         }
+      }
       if (!NonFlagUse)
         break;
     }

Modified: llvm/branches/Apple/Zoidberg/test/CodeGen/X86/and-su.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/test/CodeGen/X86/and-su.ll?rev=92895&r1=92894&r2=92895&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/test/CodeGen/X86/and-su.ll (original)
+++ llvm/branches/Apple/Zoidberg/test/CodeGen/X86/and-su.ll Wed Jan  6 20:04:27 2010
@@ -1,16 +1,53 @@
-; RUN: llc < %s -march=x86 | grep {(%} | count 1
+; RUN: llc < %s -march=x86 | FileCheck %s
 
 ; Don't duplicate the load.
 
 define fastcc i32 @foo(i32* %p) nounwind {
+; CHECK: foo:
+; CHECK: andl $10, %eax
+; CHECK: je
 	%t0 = load i32* %p
 	%t2 = and i32 %t0, 10
 	%t3 = icmp ne i32 %t2, 0
 	br i1 %t3, label %bb63, label %bb76
-
 bb63:
 	ret i32 %t2
-
 bb76:
 	ret i32 0
 }
+
+define fastcc double @bar(i32 %hash, double %x, double %y) nounwind {
+entry:
+; CHECK: bar:
+  %0 = and i32 %hash, 15
+  %1 = icmp ult i32 %0, 8
+  br i1 %1, label %bb11, label %bb10
+
+bb10:
+; CHECK: bb10
+; CHECK: testb $1
+  %2 = and i32 %hash, 1
+  %3 = icmp eq i32 %2, 0
+  br i1 %3, label %bb13, label %bb11
+
+bb11:
+  %4 = fsub double -0.000000e+00, %x
+  br label %bb13
+
+bb13:
+; CHECK: bb13
+; CHECK: testb $2
+  %iftmp.9.0 = phi double [ %4, %bb11 ], [ %x, %bb10 ]
+  %5 = and i32 %hash, 2
+  %6 = icmp eq i32 %5, 0
+  br i1 %6, label %bb16, label %bb14
+
+bb14:
+  %7 = fsub double -0.000000e+00, %y
+  br label %bb16
+
+bb16:
+  %iftmp.10.0 = phi double [ %7, %bb14 ], [ %y, %bb13 ]
+  %8 = fadd double %iftmp.9.0, %iftmp.10.0
+  ret double %8
+}

Modified: llvm/branches/Apple/Zoidberg/test/CodeGen/X86/test-nofold.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/test/CodeGen/X86/test-nofold.ll?rev=92895&r1=92894&r2=92895&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/test/CodeGen/X86/test-nofold.ll (original)
+++ llvm/branches/Apple/Zoidberg/test/CodeGen/X86/test-nofold.ll Wed Jan  6 20:04:27 2010
@@ -1,22 +1,35 @@
-; RUN: llc < %s -march=x86 -mcpu=yonah | grep {testl.*%e.x.*%e.x}
+; RUN: llc < %s -march=x86 -mcpu=yonah | FileCheck %s
 ; rdar://5752025
 
-; We don't want to fold the and into the test, because the and clobbers its
-; input forcing a copy.  We want:
-;	movl	$15, %ecx
+; We want:
+;      CHECK: movl	4(%esp), %ecx
+; CHECK-NEXT: andl	$15, %ecx
+; CHECK-NEXT: movl	$42, %eax
+; CHECK-NEXT: cmovel	%ecx, %eax
+; CHECK-NEXT: ret
+;
+; We don't want:
+;	movl	4(%esp), %eax
+;	movl	%eax, %ecx     # bad: extra copy
+;	andl	$15, %ecx
+;	testl	$15, %eax      # bad: peep obstructed
+;	movl	$42, %eax
+;	cmovel	%ecx, %eax
+;	ret
+;
+; We also don't want:
+;	movl	$15, %ecx      # bad: larger encoding
 ;	andl	4(%esp), %ecx
-;	testl	%ecx, %ecx
 ;	movl	$42, %eax
-;	cmove	%ecx, %eax
+;	cmovel	%ecx, %eax
 ;	ret
 ;
-; Not:
-;	movl	4(%esp), %eax
-;	movl	%eax, %ecx
+; We also don't want:
+;	movl	4(%esp), %ecx
 ;	andl	$15, %ecx
-;	testl	$15, %eax
+;	testl	%ecx, %ecx     # bad: unnecessary test
 ;	movl	$42, %eax
-;	cmove	%ecx, %eax
+;	cmovel	%ecx, %eax
 ;	ret
 
 define i32 @t1(i32 %X) nounwind  {
@@ -26,4 +39,3 @@
 	%retval = select i1 %tmp4, i32 %tmp2, i32 42		; <i32> [#uses=1]
 	ret i32 %retval
 }
-





More information about the llvm-branch-commits mailing list