1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -S -indvars -verify -loop-rotate -loop-idiom < %s | FileCheck %s
3target triple = "x86_64-unknown-linux-gnu"
4
5; Verify that we invalidate SCEV properly.
6
7define void @test_01() {
8; CHECK-LABEL: @test_01(
9; CHECK-NEXT:  entry:
10; CHECK-NEXT:    br label [[LBL1:%.*]]
11; CHECK:       lbl1:
12; CHECK-NEXT:    br label [[FOR_COND:%.*]]
13; CHECK:       for.cond:
14; CHECK-NEXT:    br i1 false, label [[FOR_BODY3_LR_PH:%.*]], label [[FOR_COND_FOR_END5_CRIT_EDGE:%.*]]
15; CHECK:       for.body3.lr.ph:
16; CHECK-NEXT:    br label [[FOR_BODY3:%.*]]
17; CHECK:       for.cond1:
18; CHECK-NEXT:    br i1 false, label [[FOR_BODY3]], label [[FOR_COND1_FOR_END5_CRIT_EDGE:%.*]]
19; CHECK:       for.body3:
20; CHECK-NEXT:    br i1 false, label [[IF_THEN:%.*]], label [[FOR_COND1:%.*]]
21; CHECK:       if.then:
22; CHECK-NEXT:    br label [[LBL1]]
23; CHECK:       for.cond.for.end5_crit_edge:
24; CHECK-NEXT:    br label [[FOR_END5:%.*]]
25; CHECK:       for.cond1.for.end5_crit_edge:
26; CHECK-NEXT:    br label [[FOR_END5]]
27; CHECK:       for.end5:
28; CHECK-NEXT:    ret void
29;
30entry:
31  br label %lbl1
32
33lbl1:                                             ; preds = %if.then, %entry
34  br label %for.cond
35
36for.cond:                                         ; preds = %lbl1
37  br label %for.cond1
38
39for.cond1:                                        ; preds = %if.end, %for.cond
40  br i1 false, label %for.body3, label %for.end5
41
42for.body3:                                        ; preds = %for.cond1
43  br i1 false, label %if.then, label %if.end
44
45if.then:                                          ; preds = %for.body3
46  br label %lbl1
47
48if.end:                                           ; preds = %for.body3
49  br label %for.cond1
50
51for.end5:                                         ; preds = %for.cond1
52  ret void
53}
54
55define void @test_02() {
56; CHECK-LABEL: @test_02(
57; CHECK-NEXT:  entry:
58; CHECK-NEXT:    br label [[LBL1:%.*]]
59; CHECK:       lbl1:
60; CHECK-NEXT:    br label [[FOR_COND:%.*]]
61; CHECK:       for.cond:
62; CHECK-NEXT:    br i1 false, label [[IF_THEN:%.*]], label [[IF_END7:%.*]]
63; CHECK:       if.then:
64; CHECK-NEXT:    br i1 false, label [[FOR_BODY_LR_PH:%.*]], label [[IF_THEN_FOR_END6_CRIT_EDGE:%.*]]
65; CHECK:       for.body.lr.ph:
66; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
67; CHECK:       for.body:
68; CHECK-NEXT:    br i1 false, label [[IF_THEN3:%.*]], label [[IF_END:%.*]]
69; CHECK:       if.then3:
70; CHECK-NEXT:    br label [[LBL1]]
71; CHECK:       if.end:
72; CHECK-NEXT:    br label [[FOR_COND4:%.*]]
73; CHECK:       for.cond4:
74; CHECK-NEXT:    br i1 false, label [[FOR_BODY]], label [[FOR_COND1_FOR_END6_CRIT_EDGE:%.*]]
75; CHECK:       if.then.for.end6_crit_edge:
76; CHECK-NEXT:    br label [[FOR_END6:%.*]]
77; CHECK:       for.cond1.for.end6_crit_edge:
78; CHECK-NEXT:    br label [[FOR_END6]]
79; CHECK:       for.end6:
80; CHECK-NEXT:    ret void
81; CHECK:       if.end7:
82; CHECK-NEXT:    unreachable
83;
84entry:
85  br label %lbl1
86
87lbl1:                                             ; preds = %if.then3, %entry
88  br label %for.cond
89
90for.cond:                                         ; preds = %lbl1
91  br i1 false, label %if.then, label %if.end7
92
93if.then:                                          ; preds = %for.cond
94  br label %for.cond1
95
96for.cond1:                                        ; preds = %for.cond4, %if.then
97  br i1 undef, label %for.body, label %for.end6
98
99for.body:                                         ; preds = %for.cond1
100  br i1 false, label %if.then3, label %if.end
101
102if.then3:                                         ; preds = %for.body
103  br label %lbl1
104
105if.end:                                           ; preds = %for.body
106  br label %for.cond4
107
108for.cond4:                                        ; preds = %if.end
109  br label %for.cond1
110
111for.end6:                                         ; preds = %for.cond1
112  ret void
113
114if.end7:                                          ; preds = %for.cond
115  unreachable
116}
117