Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 23d36c6

Browse files
committed
Merging r298604:
------------------------------------------------------------------------ r298604 | niravd | 2017-03-23 11:01:50 -0400 (Thu, 23 Mar 2017) | 14 lines [SDAG] Fix zeroExtend assertion error Move CombineTo preventing deleted node from being returned in visitZERO_EXTEND. Fixes PR32284. Reviewers: RKSimon, bogner Reviewed By: RKSimon Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31254 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_40@300979 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 3b2360f commit 23d36c6

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6677,13 +6677,14 @@ SDValue DAGCombiner::visitZERO_EXTEND(SDNode *N) {
66776677
LN0->getChain(),
66786678
LN0->getBasePtr(), N0.getValueType(),
66796679
LN0->getMemOperand());
6680-
CombineTo(N, ExtLoad);
6680+
66816681
SDValue Trunc = DAG.getNode(ISD::TRUNCATE, SDLoc(N0),
66826682
N0.getValueType(), ExtLoad);
66836683
CombineTo(N0.getNode(), Trunc, ExtLoad.getValue(1));
66846684

66856685
ExtendSetCCUses(SetCCs, Trunc, ExtLoad, SDLoc(N),
66866686
ISD::ZERO_EXTEND);
6687+
CombineTo(N, ExtLoad);
66876688
return SDValue(N, 0); // Return N so it doesn't get rechecked!
66886689
}
66896690
}

test/CodeGen/X86/pr32284.ll

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
; RUN: llc -O0 -mtriple=i686-unknown -mcpu=skx -o - %s
2+
; RUN: llc -O0 -mtriple=x86_64-unknown -mcpu=skx -o - %s
3+
; RUN: llc -mtriple=i686-unknown -mcpu=skx -o - %s
4+
; RUN: llc -mtriple=x86_64-unknown -mcpu=skx -o - %s
5+
6+
@c = external constant i8, align 1
7+
8+
define void @foo() {
9+
entry:
10+
%a = alloca i8, align 1
11+
%b = alloca i32, align 4
12+
%0 = load i8, i8* @c, align 1
13+
%conv = zext i8 %0 to i32
14+
%sub = sub nsw i32 0, %conv
15+
%conv1 = sext i32 %sub to i64
16+
%sub2 = sub nsw i64 0, %conv1
17+
%conv3 = trunc i64 %sub2 to i8
18+
%tobool = icmp ne i8 %conv3, 0
19+
%frombool = zext i1 %tobool to i8
20+
store i8 %frombool, i8* %a, align 1
21+
%1 = load i8, i8* @c, align 1
22+
%tobool4 = icmp ne i8 %1, 0
23+
%lnot = xor i1 %tobool4, true
24+
%lnot5 = xor i1 %lnot, true
25+
%conv6 = zext i1 %lnot5 to i32
26+
%2 = load i8, i8* @c, align 1
27+
%conv7 = zext i8 %2 to i32
28+
%cmp = icmp sle i32 %conv6, %conv7
29+
%conv8 = zext i1 %cmp to i32
30+
store i32 %conv8, i32* %b, align 4
31+
ret void
32+
}

0 commit comments

Comments
 (0)