Skip to content

Commit 48bc24b

Browse files
committed
Merge 98203 from mainline.
fix PR6533 by updating the br(xor) code to remember the case when it looked past a trunc. llvm-svn: 98306
1 parent 122bda5 commit 48bc24b

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4605,7 +4605,7 @@ SDValue DAGCombiner::visitBRCOND(SDNode *N) {
46054605

46064606
SDNode *Trunc = 0;
46074607
if (N1.getOpcode() == ISD::TRUNCATE && N1.hasOneUse()) {
4608-
// Look pass truncate.
4608+
// Look past truncate.
46094609
Trunc = N1.getNode();
46104610
N1 = N1.getOperand(0);
46114611
}
@@ -4700,7 +4700,9 @@ SDValue DAGCombiner::visitBRCOND(SDNode *N) {
47004700
Equal = true;
47014701
}
47024702

4703-
EVT SetCCVT = N1.getValueType();
4703+
SDValue NodeToReplace = Trunc ? SDValue(Trunc, 0) : N1;
4704+
4705+
EVT SetCCVT = NodeToReplace.getValueType();
47044706
if (LegalTypes)
47054707
SetCCVT = TLI.getSetCCResultType(SetCCVT);
47064708
SDValue SetCC = DAG.getSetCC(TheXor->getDebugLoc(),
@@ -4709,9 +4711,9 @@ SDValue DAGCombiner::visitBRCOND(SDNode *N) {
47094711
Equal ? ISD::SETEQ : ISD::SETNE);
47104712
// Replace the uses of XOR with SETCC
47114713
WorkListRemover DeadNodes(*this);
4712-
DAG.ReplaceAllUsesOfValueWith(N1, SetCC, &DeadNodes);
4713-
removeFromWorkList(N1.getNode());
4714-
DAG.DeleteNode(N1.getNode());
4714+
DAG.ReplaceAllUsesOfValueWith(NodeToReplace, SetCC, &DeadNodes);
4715+
removeFromWorkList(NodeToReplace.getNode());
4716+
DAG.DeleteNode(NodeToReplace.getNode());
47154717
return DAG.getNode(ISD::BRCOND, N->getDebugLoc(),
47164718
MVT::Other, Chain, SetCC, N2);
47174719
}

llvm/test/CodeGen/X86/crash.ll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,18 @@ entry:
1818
volatile store i32 %conv19.i, i32* undef
1919
ret i32 undef
2020
}
21+
22+
; PR6533
23+
define void @test2(i1 %x, i32 %y) nounwind {
24+
%land.ext = zext i1 %x to i32 ; <i32> [#uses=1]
25+
%and = and i32 %y, 1 ; <i32> [#uses=1]
26+
%xor = xor i32 %and, %land.ext ; <i32> [#uses=1]
27+
%cmp = icmp eq i32 %xor, 1 ; <i1> [#uses=1]
28+
br i1 %cmp, label %if.end, label %if.then
29+
30+
if.then: ; preds = %land.end
31+
ret void
32+
33+
if.end: ; preds = %land.end
34+
ret void
35+
}

0 commit comments

Comments
 (0)