llvm.org GIT mirror llvm / f92edff
[SDAG] Deal with deleted node in PromoteIntShiftOp Deal with case that initial node is deleted during dag-combine leading to an assertional failure in promoteIntShiftOp. Fixes PR32420. Reviewers: spatel, RKSimon Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31403 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298931 91177308-0d34-0410-b5e6-96231b3b80d8 Nirav Dave 3 years ago
2 changed file(s) with 47 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
11431143 if (TLI.IsDesirableToPromoteOp(Op, PVT)) {
11441144 assert(PVT != VT && "Don't know what type to promote to!");
11451145
1146 DEBUG(dbgs() << "\nPromoting "; Op.getNode()->dump(&DAG));
1147
11461148 bool Replace = false;
11471149 SDValue N0 = Op.getOperand(0);
1150 SDValue N1 = Op.getOperand(1);
11481151 if (Opc == ISD::SRA)
11491152 N0 = SExtPromoteOperand(N0, PVT);
11501153 else if (Opc == ISD::SRL)
11511154 N0 = ZExtPromoteOperand(N0, PVT);
11521155 else
11531156 N0 = PromoteOperand(N0, PVT, Replace);
1157
11541158 if (!N0.getNode())
11551159 return SDValue();
1160
1161 SDLoc DL(Op);
1162 SDValue RV =
1163 DAG.getNode(ISD::TRUNCATE, DL, VT, DAG.getNode(Opc, DL, PVT, N0, N1));
11561164
11571165 AddToWorklist(N0.getNode());
11581166 if (Replace)
11591167 ReplaceLoadWithPromotedLoad(Op.getOperand(0).getNode(), N0.getNode());
11601168
1161 DEBUG(dbgs() << "\nPromoting ";
1162 Op.getNode()->dump(&DAG));
1163 SDLoc DL(Op);
1164 return DAG.getNode(ISD::TRUNCATE, DL, VT,
1165 DAG.getNode(Opc, DL, PVT, N0, Op.getOperand(1)));
1169 // Deal with Op being deleted.
1170 if (Op && Op.getOpcode() != ISD::DELETED_NODE)
1171 return RV;
11661172 }
11671173 return SDValue();
11681174 }
0 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
1 ; RUN: llc < %s | FileCheck %s
2
3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-apple-macosx10.12.0"
5
6 @a = common local_unnamed_addr global i16 0, align 4
7 @b = common local_unnamed_addr global i16 0, align 4
8
9 define i32 @PR32420() {
10 ; CHECK-LABEL: PR32420:
11 ; CHECK: ## BB#0:
12 ; CHECK-NEXT: movq _a@{{.*}}(%rip), %rax
13 ; CHECK-NEXT: movzwl (%rax), %eax
14 ; CHECK-NEXT: movl %eax, %ecx
15 ; CHECK-NEXT: shll $12, %ecx
16 ; CHECK-NEXT: sarw $12, %cx
17 ; CHECK-NEXT: movq _b@{{.*}}(%rip), %rdx
18 ; CHECK-NEXT: movw %cx, %si
19 ; CHECK-NEXT: orw (%rdx), %si
20 ; CHECK-NEXT: andl %ecx, %esi
21 ; CHECK-NEXT: movw %si, (%rdx)
22 ; CHECK-NEXT: retq
23 %load2 = load i16, i16* @a, align 4
24 %shl3 = shl i16 %load2, 12
25 %ashr4 = ashr i16 %shl3, 12
26 %t2 = load volatile i16, i16* @b, align 4
27 %conv8 = or i16 %t2, %ashr4
28 %load9 = load i16, i16* @a, align 4
29 %shl10 = shl i16 %load9, 12
30 %ashr11 = ashr i16 %shl10, 12
31 %and = and i16 %conv8, %ashr11
32 store i16 %and, i16* @b, align 4
33 %cast1629 = zext i16 %load2 to i32
34 ret i32 %cast1629
35 }