Skip to content

Commit 404af37

Browse files
committed
[VPlan] Remove stale assertion in HCFG builder.
The assertion was left over from a time when VPBBs still had an associated condition bit. This is not the case any more (comment was stale). In case a branch on condition is needed, a BranchOnCond VPInstruction is added when constructing recipes. That's also where it is checked if the condition is available. Exposed by 38376de.
1 parent c2e5142 commit 404af37

File tree

2 files changed

+72
-4
lines changed

2 files changed

+72
-4
lines changed

llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,10 +439,6 @@ void PlainCFGBuilder::buildPlainCFG(
439439
}
440440
assert(BI->isConditional() && NumSuccs == 2 && BI->isConditional() &&
441441
"block must have conditional branch with 2 successors");
442-
// Look up the branch condition to get the corresponding VPValue
443-
// representing the condition bit in VPlan (which may be in another VPBB).
444-
assert(IRDef2VPValue.contains(BI->getCondition()) &&
445-
"Missing condition bit in IRDef2VPValue!");
446442

447443
BasicBlock *IRSucc0 = BI->getSuccessor(0);
448444
BasicBlock *IRSucc1 = BI->getSuccessor(1);
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt -S -passes=loop-vectorize -force-vector-width=2 < %s | FileCheck %s
3+
4+
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5+
6+
define i16 @multiple_exit_one_with_constant_condition(ptr %dst, i64 %x) {
7+
; CHECK-LABEL: @multiple_exit_one_with_constant_condition(
8+
; CHECK-NEXT: entry:
9+
; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[X:%.*]], 1
10+
; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ule i64 [[TMP0]], 2
11+
; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
12+
; CHECK: vector.ph:
13+
; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[TMP0]], 2
14+
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[N_MOD_VF]], 0
15+
; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i64 2, i64 [[N_MOD_VF]]
16+
; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[TMP0]], [[TMP2]]
17+
; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
18+
; CHECK: vector.body:
19+
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
20+
; CHECK-NEXT: [[TMP3:%.*]] = add i64 [[INDEX]], 0
21+
; CHECK-NEXT: [[TMP4:%.*]] = add i64 [[INDEX]], 1
22+
; CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds i32, ptr [[DST:%.*]], i64 [[TMP3]]
23+
; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds i32, ptr [[DST]], i64 [[TMP4]]
24+
; CHECK-NEXT: store i64 0, ptr [[TMP5]], align 8
25+
; CHECK-NEXT: store i64 0, ptr [[TMP6]], align 8
26+
; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 2
27+
; CHECK-NEXT: [[TMP7:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
28+
; CHECK-NEXT: br i1 [[TMP7]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
29+
; CHECK: middle.block:
30+
; CHECK-NEXT: br label [[SCALAR_PH]]
31+
; CHECK: scalar.ph:
32+
; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
33+
; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]
34+
; CHECK: loop.header:
35+
; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ]
36+
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i32, ptr [[DST]], i64 [[IV]]
37+
; CHECK-NEXT: store i64 0, ptr [[GEP]], align 8
38+
; CHECK-NEXT: br i1 true, label [[LOOP_THEN:%.*]], label [[EXIT_2:%.*]]
39+
; CHECK: loop.then:
40+
; CHECK-NEXT: [[CMP3:%.*]] = icmp ne i64 [[IV]], [[X]]
41+
; CHECK-NEXT: br i1 [[CMP3]], label [[LOOP_LATCH]], label [[EXIT_1:%.*]]
42+
; CHECK: loop.latch:
43+
; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
44+
; CHECK-NEXT: br label [[LOOP_HEADER]], !llvm.loop [[LOOP3:![0-9]+]]
45+
; CHECK: exit.1:
46+
; CHECK-NEXT: ret i16 0
47+
; CHECK: exit.2:
48+
; CHECK-NEXT: ret i16 1
49+
;
50+
entry:
51+
br label %loop.header
52+
53+
loop.header:
54+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]
55+
%gep = getelementptr inbounds i32, ptr %dst, i64 %iv
56+
store i64 0, ptr %gep
57+
br i1 true, label %loop.then, label %exit.2
58+
59+
loop.then:
60+
%cmp3 = icmp ne i64 %iv, %x
61+
br i1 %cmp3, label %loop.latch, label %exit.1
62+
63+
loop.latch:
64+
%iv.next = add i64 %iv, 1
65+
br label %loop.header
66+
67+
exit.1:
68+
ret i16 0
69+
70+
exit.2:
71+
ret i16 1
72+
}

0 commit comments

Comments
 (0)