diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2010-01-07 00:54:06 +0000 | 
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2010-01-07 00:54:06 +0000 | 
| commit | 90dc43fcf520c31e000308659440b2c300cce0f7 (patch) | |
| tree | 0afb3a689ef6b9a7223002f8c6c532c087b5d3b7 /llvm | |
| parent | 09470e6a4eedf2bd4aa5cc589a966f01e65f6b3d (diff) | |
| download | bcm5719-llvm-90dc43fcf520c31e000308659440b2c300cce0f7.tar.gz bcm5719-llvm-90dc43fcf520c31e000308659440b2c300cce0f7.zip  | |
Fix a minor regression from my dag combiner changes. One more place which needs to look pass truncates.
llvm-svn: 92885
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 16 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/and-su.ll | 43 | 
2 files changed, 52 insertions, 7 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 7d92fd8fad6..212478c58ab 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -5611,13 +5611,21 @@ SDValue X86TargetLowering::EmitTest(SDValue Op, unsigned X86CC,        // 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.getOperandNo() != 0) && -            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;      } diff --git a/llvm/test/CodeGen/X86/and-su.ll b/llvm/test/CodeGen/X86/and-su.ll index b5ac23b2412..38db88af12c 100644 --- a/llvm/test/CodeGen/X86/and-su.ll +++ b/llvm/test/CodeGen/X86/and-su.ll @@ -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 +}  | 

