1; RUN: opt -scalar-evolution-max-arith-depth=4 -scalar-evolution-max-add-rec-size=4 -loop-reduce -S < %s | FileCheck %s 2 3; Check that the test does not hang. 4define void @test_01(i32* nocapture %a) local_unnamed_addr { 5 6; CHECK-LABEL: @test_01( 7 8while.body.outer: 9 %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 96 10 %arrayidx2.promoted50 = load i32, i32* %arrayidx2, align 1 11 %a.promoted = load i32, i32* %a, align 1 12 %add347.peel = xor i32 %arrayidx2.promoted50, -1 13 %tobool48.peel = icmp eq i32 %a.promoted, %add347.peel 14 br i1 %tobool48.peel, label %while.body.preheader, label %while.body4.preheader 15 16while.body.preheader: ; preds = %while.body.outer 17 %tobool48 = icmp eq i32 %a.promoted, 1 18 br label %while.body 19 20while.body: ; preds = %while.body.preheader, %while.body 21 br i1 %tobool48, label %while.body, label %while.body4.preheader.loopexit 22 23while.body4.preheader.loopexit: ; preds = %while.body 24 br label %while.body4.preheader 25 26while.body4.preheader: ; preds = %while.body4.preheader.loopexit, %while.body.outer 27 br label %while.body4 28 29while.body4: ; preds = %while.body4.preheader, %while.end.22 30 %0 = phi i32 [ %mul.22, %while.end.22 ], [ %arrayidx2.promoted50, %while.body4.preheader ] 31 %mul = mul nsw i32 %0, %0 32 br label %while.cond17 33 34while.cond17: ; preds = %while.cond17, %while.body4 35 %add22.sink = phi i32 [ %add22, %while.cond17 ], [ %mul, %while.body4 ] 36 %cmp = icmp slt i32 %add22.sink, 0 37 %add22 = add nsw i32 %add22.sink, 1024 38 br i1 %cmp, label %while.cond17, label %while.end 39 40while.end: ; preds = %while.cond17 41 %mul.1 = mul nsw i32 %add22.sink, %add22.sink 42 br label %while.cond17.1 43 44while.cond17.1: ; preds = %while.cond17.1, %while.end 45 %add22.sink.1 = phi i32 [ %add22.1, %while.cond17.1 ], [ %mul.1, %while.end ] 46 %cmp.1 = icmp slt i32 %add22.sink.1, 0 47 %add22.1 = add nsw i32 %add22.sink.1, 2048 48 br i1 %cmp.1, label %while.cond17.1, label %while.end.1 49 50while.end.1: ; preds = %while.cond17.1 51 %mul.2 = mul nsw i32 %add22.sink.1, %add22.sink.1 52 br label %while.cond17.2 53 54while.cond17.2: ; preds = %while.cond17.2, %while.end.1 55 %add22.sink.2 = phi i32 [ %add22.2, %while.cond17.2 ], [ %mul.2, %while.end.1 ] 56 %cmp.2 = icmp slt i32 %add22.sink.2, 0 57 %add22.2 = add nsw i32 %add22.sink.2, 4096 58 br i1 %cmp.2, label %while.cond17.2, label %while.end.2 59 60while.end.2: ; preds = %while.cond17.2 61 %mul.3 = mul nsw i32 %add22.sink.2, %add22.sink.2 62 br label %while.cond17.3 63 64while.cond17.3: ; preds = %while.cond17.3, %while.end.2 65 %add22.sink.3 = phi i32 [ %add22.3, %while.cond17.3 ], [ %mul.3, %while.end.2 ] 66 %cmp.3 = icmp slt i32 %add22.sink.3, 0 67 %add22.3 = add nsw i32 %add22.sink.3, 8192 68 br i1 %cmp.3, label %while.cond17.3, label %while.end.3 69 70while.end.3: ; preds = %while.cond17.3 71 %mul.4 = mul nsw i32 %add22.sink.3, %add22.sink.3 72 br label %while.cond17.4 73 74while.cond17.4: ; preds = %while.cond17.4, %while.end.3 75 %add22.sink.4 = phi i32 [ %add22.4, %while.cond17.4 ], [ %mul.4, %while.end.3 ] 76 %cmp.4 = icmp slt i32 %add22.sink.4, 0 77 %add22.4 = add nsw i32 %add22.sink.4, 16384 78 br i1 %cmp.4, label %while.cond17.4, label %while.end.4 79 80while.end.4: ; preds = %while.cond17.4 81 %mul.5 = mul nsw i32 %add22.sink.4, %add22.sink.4 82 br label %while.cond17.5 83 84while.cond17.5: ; preds = %while.cond17.5, %while.end.4 85 %add22.sink.5 = phi i32 [ %add22.5, %while.cond17.5 ], [ %mul.5, %while.end.4 ] 86 %cmp.5 = icmp slt i32 %add22.sink.5, 0 87 %add22.5 = add nsw i32 %add22.sink.5, 32768 88 br i1 %cmp.5, label %while.cond17.5, label %while.end.5 89 90while.end.5: ; preds = %while.cond17.5 91 %mul.6 = mul nsw i32 %add22.sink.5, %add22.sink.5 92 br label %while.cond17.6 93 94while.cond17.6: ; preds = %while.cond17.6, %while.end.5 95 %add22.sink.6 = phi i32 [ %add22.6, %while.cond17.6 ], [ %mul.6, %while.end.5 ] 96 %cmp.6 = icmp slt i32 %add22.sink.6, 0 97 %add22.6 = add nsw i32 %add22.sink.6, 65536 98 br i1 %cmp.6, label %while.cond17.6, label %while.end.6 99 100while.end.6: ; preds = %while.cond17.6 101 %mul.7 = mul nsw i32 %add22.sink.6, %add22.sink.6 102 br label %while.cond17.7 103 104while.cond17.7: ; preds = %while.cond17.7, %while.end.6 105 %add22.sink.7 = phi i32 [ %add22.7, %while.cond17.7 ], [ %mul.7, %while.end.6 ] 106 %cmp.7 = icmp slt i32 %add22.sink.7, 0 107 %add22.7 = add nsw i32 %add22.sink.7, 131072 108 br i1 %cmp.7, label %while.cond17.7, label %while.end.7 109 110while.end.7: ; preds = %while.cond17.7 111 %mul.8 = mul nsw i32 %add22.sink.7, %add22.sink.7 112 br label %while.cond17.8 113 114while.cond17.8: ; preds = %while.cond17.8, %while.end.7 115 %add22.sink.8 = phi i32 [ %add22.8, %while.cond17.8 ], [ %mul.8, %while.end.7 ] 116 %cmp.8 = icmp slt i32 %add22.sink.8, 0 117 %add22.8 = add nsw i32 %add22.sink.8, 262144 118 br i1 %cmp.8, label %while.cond17.8, label %while.end.8 119 120while.end.8: ; preds = %while.cond17.8 121 %mul.9 = mul nsw i32 %add22.sink.8, %add22.sink.8 122 br label %while.cond17.9 123 124while.cond17.9: ; preds = %while.cond17.9, %while.end.8 125 %add22.sink.9 = phi i32 [ %add22.9, %while.cond17.9 ], [ %mul.9, %while.end.8 ] 126 %cmp.9 = icmp slt i32 %add22.sink.9, 0 127 %add22.9 = add nsw i32 %add22.sink.9, 524288 128 br i1 %cmp.9, label %while.cond17.9, label %while.end.9 129 130while.end.9: ; preds = %while.cond17.9 131 %mul.10 = mul nsw i32 %add22.sink.9, %add22.sink.9 132 br label %while.cond17.10 133 134while.cond17.10: ; preds = %while.cond17.10, %while.end.9 135 %add22.sink.10 = phi i32 [ %add22.10, %while.cond17.10 ], [ %mul.10, %while.end.9 ] 136 %cmp.10 = icmp slt i32 %add22.sink.10, 0 137 %add22.10 = add nsw i32 %add22.sink.10, 1048576 138 br i1 %cmp.10, label %while.cond17.10, label %while.end.10 139 140while.end.10: ; preds = %while.cond17.10 141 %mul.11 = mul nsw i32 %add22.sink.10, %add22.sink.10 142 br label %while.cond17.11 143 144while.cond17.11: ; preds = %while.cond17.11, %while.end.10 145 %add22.sink.11 = phi i32 [ %add22.11, %while.cond17.11 ], [ %mul.11, %while.end.10 ] 146 %cmp.11 = icmp slt i32 %add22.sink.11, 0 147 %add22.11 = add nsw i32 %add22.sink.11, 2097152 148 br i1 %cmp.11, label %while.cond17.11, label %while.end.11 149 150while.end.11: ; preds = %while.cond17.11 151 %mul.12 = mul nsw i32 %add22.sink.11, %add22.sink.11 152 br label %while.cond17.12 153 154while.cond17.12: ; preds = %while.cond17.12, %while.end.11 155 %add22.sink.12 = phi i32 [ %add22.12, %while.cond17.12 ], [ %mul.12, %while.end.11 ] 156 %cmp.12 = icmp slt i32 %add22.sink.12, 0 157 %add22.12 = add nsw i32 %add22.sink.12, 4194304 158 br i1 %cmp.12, label %while.cond17.12, label %while.end.12 159 160while.end.12: ; preds = %while.cond17.12 161 %mul.13 = mul nsw i32 %add22.sink.12, %add22.sink.12 162 br label %while.cond17.13 163 164while.cond17.13: ; preds = %while.cond17.13, %while.end.12 165 %add22.sink.13 = phi i32 [ %add22.13, %while.cond17.13 ], [ %mul.13, %while.end.12 ] 166 %cmp.13 = icmp slt i32 %add22.sink.13, 0 167 %add22.13 = add nsw i32 %add22.sink.13, 8388608 168 br i1 %cmp.13, label %while.cond17.13, label %while.end.13 169 170while.end.13: ; preds = %while.cond17.13 171 %mul.14 = mul nsw i32 %add22.sink.13, %add22.sink.13 172 br label %while.cond17.14 173 174while.cond17.14: ; preds = %while.cond17.14, %while.end.13 175 %add22.sink.14 = phi i32 [ %add22.14, %while.cond17.14 ], [ %mul.14, %while.end.13 ] 176 %cmp.14 = icmp slt i32 %add22.sink.14, 0 177 %add22.14 = add nsw i32 %add22.sink.14, 16777216 178 br i1 %cmp.14, label %while.cond17.14, label %while.end.14 179 180while.end.14: ; preds = %while.cond17.14 181 %mul.15 = mul nsw i32 %add22.sink.14, %add22.sink.14 182 br label %while.cond17.15 183 184while.cond17.15: ; preds = %while.cond17.15, %while.end.14 185 %add22.sink.15 = phi i32 [ %add22.15, %while.cond17.15 ], [ %mul.15, %while.end.14 ] 186 %cmp.15 = icmp slt i32 %add22.sink.15, 0 187 %add22.15 = add nsw i32 %add22.sink.15, 33554432 188 br i1 %cmp.15, label %while.cond17.15, label %while.end.15 189 190while.end.15: ; preds = %while.cond17.15 191 %mul.16 = mul nsw i32 %add22.sink.15, %add22.sink.15 192 br label %while.cond17.16 193 194while.cond17.16: ; preds = %while.cond17.16, %while.end.15 195 %add22.sink.16 = phi i32 [ %add22.16, %while.cond17.16 ], [ %mul.16, %while.end.15 ] 196 %cmp.16 = icmp slt i32 %add22.sink.16, 0 197 %add22.16 = add nsw i32 %add22.sink.16, 67108864 198 br i1 %cmp.16, label %while.cond17.16, label %while.end.16 199 200while.end.16: ; preds = %while.cond17.16 201 %mul.17 = mul nsw i32 %add22.sink.16, %add22.sink.16 202 br label %while.cond17.17 203 204while.cond17.17: ; preds = %while.cond17.17, %while.end.16 205 %add22.sink.17 = phi i32 [ %add22.17, %while.cond17.17 ], [ %mul.17, %while.end.16 ] 206 %cmp.17 = icmp slt i32 %add22.sink.17, 0 207 %add22.17 = add nsw i32 %add22.sink.17, 134217728 208 br i1 %cmp.17, label %while.cond17.17, label %while.end.17 209 210while.end.17: ; preds = %while.cond17.17 211 %mul.18 = mul nsw i32 %add22.sink.17, %add22.sink.17 212 br label %while.cond17.18 213 214while.cond17.18: ; preds = %while.cond17.18, %while.end.17 215 %add22.sink.18 = phi i32 [ %add22.18, %while.cond17.18 ], [ %mul.18, %while.end.17 ] 216 %cmp.18 = icmp slt i32 %add22.sink.18, 0 217 %add22.18 = add nsw i32 %add22.sink.18, 268435456 218 br i1 %cmp.18, label %while.cond17.18, label %while.end.18 219 220while.end.18: ; preds = %while.cond17.18 221 %mul.19 = mul nsw i32 %add22.sink.18, %add22.sink.18 222 br label %while.cond17.19 223 224while.cond17.19: ; preds = %while.cond17.19, %while.end.18 225 %add22.sink.19 = phi i32 [ %add22.19, %while.cond17.19 ], [ %mul.19, %while.end.18 ] 226 %cmp.19 = icmp slt i32 %add22.sink.19, 0 227 %add22.19 = add nsw i32 %add22.sink.19, 536870912 228 br i1 %cmp.19, label %while.cond17.19, label %while.end.19 229 230while.end.19: ; preds = %while.cond17.19 231 %mul.20 = mul nsw i32 %add22.sink.19, %add22.sink.19 232 br label %while.cond17.20 233 234while.cond17.20: ; preds = %while.cond17.20, %while.end.19 235 %add22.sink.20 = phi i32 [ %add22.20, %while.cond17.20 ], [ %mul.20, %while.end.19 ] 236 %cmp.20 = icmp slt i32 %add22.sink.20, 0 237 %add22.20 = add nsw i32 %add22.sink.20, 1073741824 238 br i1 %cmp.20, label %while.cond17.20, label %while.end.20 239 240while.end.20: ; preds = %while.cond17.20 241 %mul.21 = mul nsw i32 %add22.sink.20, %add22.sink.20 242 br label %while.cond17.21 243 244while.cond17.21: ; preds = %while.cond17.21, %while.end.20 245 %add22.sink.21 = phi i32 [ %add22.21, %while.cond17.21 ], [ %mul.21, %while.end.20 ] 246 %cmp.21 = icmp slt i32 %add22.sink.21, 0 247 %add22.21 = or i32 %add22.sink.21, -2147483648 248 br i1 %cmp.21, label %while.cond17.21, label %while.end.22 249 250while.end.22: ; preds = %while.cond17.21 251 %mul.22 = mul nsw i32 %add22.sink.21, %add22.sink.21 252 br label %while.body4 253} 254