Skip to content

Commit ee9bb25

Browse files
committed
[LoopDeletion] Add test with irreducible control flow in loop.
Currently the irreducible cycles in the loops are ignored. The irreducible cycle may loop infinitely in irreducible_subloop_no_mustprogress, which is allowed and the loop should not be removed. Discussed in D103382.
1 parent abe501f commit ee9bb25

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt < %s -loop-deletion -verify-dom-info -S | FileCheck %s
3+
4+
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64"
5+
6+
define void @irreducible_subloop_no_mustprogress(i1 %c1, i1 %c2, i1 %c3) {
7+
; CHECK-LABEL: @irreducible_subloop_no_mustprogress(
8+
; CHECK-NEXT: br label [[EXIT:%.*]]
9+
; CHECK: exit:
10+
; CHECK-NEXT: ret void
11+
;
12+
br label %loop1
13+
14+
loop1:
15+
br i1 %c1, label %loop1.bb1, label %irr.bb1
16+
17+
loop1.bb1:
18+
br label %irr.bb2
19+
20+
irr.bb1:
21+
br i1 %c2, label %loop1.latch, label %irr.bb2
22+
23+
irr.bb2:
24+
br i1 %c3, label %loop1.latch, label %irr.bb1
25+
26+
loop1.latch:
27+
br i1 false, label %loop1, label %exit
28+
29+
exit:
30+
ret void
31+
}
32+
33+
define void @irreducible_subloop_with_mustprogress(i1 %c1, i1 %c2, i1 %c3) mustprogress {
34+
; CHECK-LABEL: @irreducible_subloop_with_mustprogress(
35+
; CHECK-NEXT: br label [[EXIT:%.*]]
36+
; CHECK: exit:
37+
; CHECK-NEXT: ret void
38+
;
39+
br label %loop1
40+
41+
loop1:
42+
br i1 %c1, label %loop1.bb1, label %irr.bb1
43+
44+
loop1.bb1:
45+
br label %irr.bb2
46+
47+
irr.bb1:
48+
br i1 %c2, label %loop1.latch, label %irr.bb2
49+
50+
irr.bb2:
51+
br i1 %c3, label %loop1.latch, label %irr.bb1
52+
53+
loop1.latch:
54+
br i1 false, label %loop1, label %exit
55+
56+
exit:
57+
ret void
58+
}

0 commit comments

Comments
 (0)