1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=indvars -verify-scev < %s | FileCheck %s
4 define void @test_pr54434() {
5 ; CHECK-LABEL: @test_pr54434(
7 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
9 ; CHECK-NEXT: br i1 false, label [[FOR_COND92_PREHEADER:%.*]], label [[FOR_END106:%.*]]
10 ; CHECK: for.cond92.preheader:
11 ; CHECK-NEXT: br label [[FOR_COND92:%.*]]
13 ; CHECK-NEXT: br i1 false, label [[FOR_BODY94:%.*]], label [[FOR_END:%.*]]
15 ; CHECK-NEXT: br label [[FOR_COND92]]
17 ; CHECK-NEXT: br label [[FOR_COND]]
19 ; CHECK-NEXT: ret void
24 for.cond: ; preds = %for.end, %entry
25 %0 = phi i32 [ %inc105, %for.end ], [ 0, %entry ]
26 %cmp = icmp sge i32 %0, 1
27 br i1 %cmp, label %for.cond92, label %for.end106
29 for.cond92: ; preds = %for.body94, %for.cond
30 %1 = phi i16 [ %inc, %for.body94 ], [ 0, %for.cond ]
31 %cmp93 = icmp slt i16 %1, 1
32 br i1 %cmp93, label %for.body94, label %for.end
34 for.body94: ; preds = %for.cond92
35 %inc = add nsw i16 %1, 1
38 for.end: ; preds = %for.cond92
39 %inc105 = add nsw i32 %0, 1
42 for.end106: ; preds = %for.cond
46 define i32 @test_pr58439(i32 %a) {
47 ; CHECK-LABEL: @test_pr58439(
49 ; CHECK-NEXT: br label [[LOOP:%.*]]
51 ; CHECK-NEXT: br i1 false, label [[LOOP]], label [[EXIT:%.*]]
53 ; CHECK-NEXT: [[C_EXT_LCSSA:%.*]] = phi i32 [ 0, [[LOOP]] ]
54 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[A:%.*]], 1
55 ; CHECK-NEXT: [[RES:%.*]] = add i32 [[C_EXT_LCSSA]], [[OR]]
56 ; CHECK-NEXT: ret i32 [[RES]]
63 %iv = phi i32 [ 1, %entry ], [ %iv.next, %loop ]
64 %iv.next = add i32 %iv, 1
65 %c.1 = icmp eq i32 %iv.next, %or
66 %c.ext = zext i1 %c.1 to i32
67 br i1 false, label %loop, label %exit
70 %res = add i32 %c.ext, %or
74 define i8 @l(i32 %inc, i1 %tobool.not.i) {
77 ; CHECK-NEXT: br label [[OUTER_HEADER:%.*]]
78 ; CHECK: outer.header:
79 ; CHECK-NEXT: br label [[INNER:%.*]]
81 ; CHECK-NEXT: [[C_05_I:%.*]] = phi i32 [ [[INC_I:%.*]], [[INNER]] ], [ 0, [[OUTER_HEADER]] ]
82 ; CHECK-NEXT: [[INC_I]] = add nuw nsw i32 [[C_05_I]], 1
83 ; CHECK-NEXT: [[CMP_I:%.*]] = icmp ugt i32 [[C_05_I]], 0
84 ; CHECK-NEXT: [[OR_COND_I:%.*]] = select i1 [[CMP_I]], i1 true, i1 [[TOBOOL_NOT_I:%.*]]
85 ; CHECK-NEXT: br i1 [[OR_COND_I]], label [[OUTER_LATCH:%.*]], label [[INNER]]
87 ; CHECK-NEXT: [[C_05_I_LCSSA:%.*]] = phi i32 [ [[C_05_I]], [[INNER]] ]
88 ; CHECK-NEXT: [[LCSSA:%.*]] = phi i32 [ 0, [[INNER]] ]
89 ; CHECK-NEXT: [[AND:%.*]] = and i32 1, [[INC:%.*]]
90 ; CHECK-NEXT: [[TMP0:%.*]] = trunc i32 [[AND]] to i8
91 ; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 [[C_05_I_LCSSA]] to i8
92 ; CHECK-NEXT: [[TMP2:%.*]] = sub i8 [[TMP0]], [[TMP1]]
93 ; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq i8 [[TMP2]], 0
94 ; CHECK-NEXT: br i1 [[TOBOOL_NOT]], label [[OUTER_HEADER]], label [[IF_THEN:%.*]]
96 ; CHECK-NEXT: ret i8 0
99 br label %outer.header
101 outer.header: ; preds = %h.exit, %entry
102 %outer.iv = phi i16 [ 0, %entry ], [ %outer.iv.next, %outer.latch ]
103 %and = and i32 1, %inc
104 %conv = sext i16 %outer.iv to i32
107 inner: ; preds = %while.body.i, %for.cond
108 %c.05.i = phi i32 [ %inc.i, %inner ], [ 0, %outer.header ]
109 %i.addr.04.i = phi i32 [ 0, %inner ], [ %conv, %outer.header ]
110 %inc.i = add nsw i32 %c.05.i, 1
111 %cmp.i = icmp sgt i32 %c.05.i, 0
112 %or.cond.i = select i1 %cmp.i, i1 true, i1 %tobool.not.i
113 br i1 %or.cond.i, label %outer.latch, label %inner
115 outer.latch: ; preds = %while.body.i
116 %lcssa = phi i32 [ 0, %inner ]
117 %0 = trunc i32 %and to i8
118 %1 = trunc i32 %c.05.i to i8
120 %tobool.not = icmp eq i8 %2, 0
121 %outer.iv.next = add i16 %outer.iv, 1
122 br i1 %tobool.not, label %outer.header, label %if.then
124 if.then: ; preds = %h.exit