[llvm] r207145 - X86: Don't transform shifts into ands when the sign bit is tested.
Benjamin Kramer
benny.kra at googlemail.com
Thu Apr 24 13:51:37 PDT 2014
Author: d0k
Date: Thu Apr 24 15:51:37 2014
New Revision: 207145
URL: http://llvm.org/viewvc/llvm-project?rev=207145&view=rev
Log:
X86: Don't transform shifts into ands when the sign bit is tested.
Should unbreak MultiSource/Benchmarks/mediabench/g721/g721encode/encode.
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/test/CodeGen/X86/cmp.ll
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=207145&r1=207144&r2=207145&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Apr 24 15:51:37 2014
@@ -9802,7 +9802,8 @@ SDValue X86TargetLowering::EmitTest(SDVa
// If we have a constant logical shift that's only used in a comparison
// against zero turn it into an equivalent AND. This allows turning it into
// a TEST instruction later.
- if (isa<ConstantSDNode>(Op->getOperand(1)) && !hasNonFlagsUse(Op)) {
+ if ((X86CC == X86::COND_E || X86CC == X86::COND_NE) &&
+ isa<ConstantSDNode>(Op->getOperand(1)) && !hasNonFlagsUse(Op)) {
EVT VT = Op.getValueType();
unsigned BitWidth = VT.getSizeInBits();
unsigned ShAmt = Op->getConstantOperandVal(1);
Modified: llvm/trunk/test/CodeGen/X86/cmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/cmp.ll?rev=207145&r1=207144&r2=207145&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/cmp.ll (original)
+++ llvm/trunk/test/CodeGen/X86/cmp.ll Thu Apr 24 15:51:37 2014
@@ -187,3 +187,14 @@ define i32 @test13(i32 %mask, i32 %base,
; CHECK: testb $8, %dil
; CHECK: cmovnel
}
+
+define i32 @test14(i32 %mask, i32 %base, i32 %intra) #0 {
+ %s = lshr i32 %mask, 7
+ %tobool = icmp sgt i32 %s, -1
+ %cond = select i1 %tobool, i32 %intra, i32 %base
+ ret i32 %cond
+
+; CHECK-LABEL: test14:
+; CHECK: shrl $7, %edi
+; CHECK-NEXT: cmovnsl %edx, %esi
+}
More information about the llvm-commits
mailing list