[llvm] r237828 - [X86] Remove unused node after morphing it from shr to and.
Benjamin Kramer
benny.kra at googlemail.com
Wed May 20 13:10:26 PDT 2015
Author: d0k
Date: Wed May 20 15:10:26 2015
New Revision: 237828
URL: http://llvm.org/viewvc/llvm-project?rev=237828&view=rev
Log:
[X86] Remove unused node after morphing it from shr to and.
In some cases it won't get cleaned up properly leading to crashes
downstream. PR23353.
Based on a patch by Davide Italiano.
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=237828&r1=237827&r2=237828&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed May 20 15:10:26 2015
@@ -12737,6 +12737,7 @@ SDValue X86TargetLowering::EmitTest(SDVa
SDValue New = DAG.getNode(ISD::AND, dl, VT, Op->getOperand(0),
DAG.getConstant(Mask, dl, VT));
DAG.ReplaceAllUsesWith(Op, New);
+ DAG.RemoveDeadNode(Op.getNode());
Op = New;
}
break;
Modified: llvm/trunk/test/CodeGen/X86/cmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/cmp.ll?rev=237828&r1=237827&r2=237828&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/cmp.ll (original)
+++ llvm/trunk/test/CodeGen/X86/cmp.ll Wed May 20 15:10:26 2015
@@ -211,3 +211,20 @@ define zeroext i1 @test15(i32 %bf.load,
; CHECK: shrl $16, %edi
; CHECK: cmpl %esi, %edi
}
+
+; PR23353
+define i1 @test16(i32* %a, i1* %b) {
+ %load = load i32, i32* %a
+ %trunc = trunc i32 %load to i8
+ %mul = mul i8 %trunc, 2
+ %icmp1 = icmp ne i8 %mul, 0
+ store i1 %icmp1, i1* %b
+ %and = and i8 %trunc, 127
+ %icmp2 = icmp ne i8 %and, 0
+ ret i1 %icmp2
+
+; CHECK-LABEL: test16:
+; CHECK-NOT: addb
+; CHECK-NOT: andb
+; CHECK: testb $127
+}
More information about the llvm-commits
mailing list