1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -S -loop-predication -loop-predication-predicate-widenable-branches-to-deopt=true < %s 2>&1 | FileCheck %s 3; RUN: opt -S -passes='require<scalar-evolution>,loop(loop-predication)' -loop-predication-predicate-widenable-branches-to-deopt=true < %s 2>&1 | FileCheck %s 4; RUN: opt -S -passes='require<scalar-evolution>,require<branch-prob>,loop(loop-predication)' -loop-predication-predicate-widenable-branches-to-deopt=true < %s 2>&1 | FileCheck %s 5 6declare void @llvm.experimental.guard(i1, ...) 7 8define i32 @unsigned_loop_0_to_n_ult_check(i32* %array, i32 %length, i32 %n) { 9; CHECK-LABEL: @unsigned_loop_0_to_n_ult_check( 10; CHECK-NEXT: entry: 11; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0 12; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 13; CHECK: loop.preheader: 14; CHECK-NEXT: [[TMP0:%.*]] = icmp ule i32 [[N]], [[LENGTH:%.*]] 15; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]] 16; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]] 17; CHECK-NEXT: br label [[LOOP:%.*]] 18; CHECK: loop: 19; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 20; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 21; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 22; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]] 23; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 24; CHECK: deopt: 25; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 26; CHECK-NEXT: ret i32 [[DEOPTCALL]] 27; CHECK: guarded: 28; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 29; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 30; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 31; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 32; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1 33; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]] 34; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 35; CHECK: exit.loopexit: 36; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 37; CHECK-NEXT: br label [[EXIT]] 38; CHECK: exit: 39; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 40; CHECK-NEXT: ret i32 [[RESULT]] 41; 42entry: 43 %tmp5 = icmp eq i32 %n, 0 44 br i1 %tmp5, label %exit, label %loop.preheader 45 46loop.preheader: ; preds = %entry 47 br label %loop 48 49loop: ; preds = %guarded, %loop.preheader 50 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 51 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 52 %within.bounds = icmp ult i32 %i, %length 53 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 54 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 55 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 56 57deopt: ; preds = %loop 58 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 59 ret i32 %deoptcall 60 61guarded: ; preds = %loop 62 %i.i64 = zext i32 %i to i64 63 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 64 %array.i = load i32, i32* %array.i.ptr, align 4 65 %loop.acc.next = add i32 %loop.acc, %array.i 66 %i.next = add nuw i32 %i, 1 67 %continue = icmp ult i32 %i.next, %n 68 br i1 %continue, label %loop, label %exit, !prof !2 69 70exit: ; preds = %guarded, %entry 71 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 72 ret i32 %result 73} 74 75define i32 @unsigned_loop_0_to_n_ule_latch_ult_check(i32* %array, i32 %length, i32 %n) { 76; CHECK-LABEL: @unsigned_loop_0_to_n_ule_latch_ult_check( 77; CHECK-NEXT: entry: 78; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0 79; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 80; CHECK: loop.preheader: 81; CHECK-NEXT: [[TMP0:%.*]] = icmp ult i32 [[N]], [[LENGTH:%.*]] 82; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]] 83; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]] 84; CHECK-NEXT: br label [[LOOP:%.*]] 85; CHECK: loop: 86; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 87; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 88; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 89; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]] 90; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 91; CHECK: deopt: 92; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 93; CHECK-NEXT: ret i32 [[DEOPTCALL]] 94; CHECK: guarded: 95; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 96; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 97; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 98; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 99; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1 100; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ule i32 [[I_NEXT]], [[N]] 101; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 102; CHECK: exit.loopexit: 103; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 104; CHECK-NEXT: br label [[EXIT]] 105; CHECK: exit: 106; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 107; CHECK-NEXT: ret i32 [[RESULT]] 108; 109entry: 110 %tmp5 = icmp eq i32 %n, 0 111 br i1 %tmp5, label %exit, label %loop.preheader 112 113loop.preheader: ; preds = %entry 114 br label %loop 115 116loop: ; preds = %guarded, %loop.preheader 117 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 118 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 119 %within.bounds = icmp ult i32 %i, %length 120 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 121 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 122 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 123 124deopt: ; preds = %loop 125 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 126 ret i32 %deoptcall 127 128guarded: ; preds = %loop 129 %i.i64 = zext i32 %i to i64 130 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 131 %array.i = load i32, i32* %array.i.ptr, align 4 132 %loop.acc.next = add i32 %loop.acc, %array.i 133 %i.next = add nuw i32 %i, 1 134 %continue = icmp ule i32 %i.next, %n 135 br i1 %continue, label %loop, label %exit, !prof !2 136 137exit: ; preds = %guarded, %entry 138 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 139 ret i32 %result 140} 141 142define i32 @unsigned_loop_0_to_n_ugt_check(i32* %array, i32 %length, i32 %n) { 143; CHECK-LABEL: @unsigned_loop_0_to_n_ugt_check( 144; CHECK-NEXT: entry: 145; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0 146; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 147; CHECK: loop.preheader: 148; CHECK-NEXT: [[TMP0:%.*]] = icmp ule i32 [[N]], [[LENGTH:%.*]] 149; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]] 150; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]] 151; CHECK-NEXT: br label [[LOOP:%.*]] 152; CHECK: loop: 153; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 154; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 155; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 156; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]] 157; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 158; CHECK: deopt: 159; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 160; CHECK-NEXT: ret i32 [[DEOPTCALL]] 161; CHECK: guarded: 162; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 163; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 164; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 165; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 166; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1 167; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]] 168; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 169; CHECK: exit.loopexit: 170; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 171; CHECK-NEXT: br label [[EXIT]] 172; CHECK: exit: 173; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 174; CHECK-NEXT: ret i32 [[RESULT]] 175; 176entry: 177 %tmp5 = icmp eq i32 %n, 0 178 br i1 %tmp5, label %exit, label %loop.preheader 179 180loop.preheader: ; preds = %entry 181 br label %loop 182 183loop: ; preds = %guarded, %loop.preheader 184 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 185 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 186 %within.bounds = icmp ugt i32 %length, %i 187 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 188 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 189 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 190 191deopt: ; preds = %loop 192 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 193 ret i32 %deoptcall 194 195guarded: ; preds = %loop 196 %i.i64 = zext i32 %i to i64 197 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 198 %array.i = load i32, i32* %array.i.ptr, align 4 199 %loop.acc.next = add i32 %loop.acc, %array.i 200 %i.next = add nuw i32 %i, 1 201 %continue = icmp ult i32 %i.next, %n 202 br i1 %continue, label %loop, label %exit, !prof !2 203 204exit: ; preds = %guarded, %entry 205 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 206 ret i32 %result 207} 208 209define i32 @signed_loop_0_to_n_ult_check(i32* %array, i32 %length, i32 %n) { 210; CHECK-LABEL: @signed_loop_0_to_n_ult_check( 211; CHECK-NEXT: entry: 212; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0 213; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 214; CHECK: loop.preheader: 215; CHECK-NEXT: [[TMP0:%.*]] = icmp sle i32 [[N]], [[LENGTH:%.*]] 216; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]] 217; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]] 218; CHECK-NEXT: br label [[LOOP:%.*]] 219; CHECK: loop: 220; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 221; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 222; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 223; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]] 224; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 225; CHECK: deopt: 226; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 227; CHECK-NEXT: ret i32 [[DEOPTCALL]] 228; CHECK: guarded: 229; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 230; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 231; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 232; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 233; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1 234; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]] 235; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 236; CHECK: exit.loopexit: 237; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 238; CHECK-NEXT: br label [[EXIT]] 239; CHECK: exit: 240; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 241; CHECK-NEXT: ret i32 [[RESULT]] 242; 243 244entry: 245 %tmp5 = icmp sle i32 %n, 0 246 br i1 %tmp5, label %exit, label %loop.preheader 247 248loop.preheader: ; preds = %entry 249 br label %loop 250 251loop: ; preds = %guarded, %loop.preheader 252 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 253 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 254 %within.bounds = icmp ult i32 %i, %length 255 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 256 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 257 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 258 259deopt: ; preds = %loop 260 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 261 ret i32 %deoptcall 262 263guarded: ; preds = %loop 264 %i.i64 = zext i32 %i to i64 265 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 266 %array.i = load i32, i32* %array.i.ptr, align 4 267 %loop.acc.next = add i32 %loop.acc, %array.i 268 %i.next = add nuw i32 %i, 1 269 %continue = icmp slt i32 %i.next, %n 270 br i1 %continue, label %loop, label %exit, !prof !2 271 272exit: ; preds = %guarded, %entry 273 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 274 ret i32 %result 275} 276 277define i32 @signed_loop_0_to_n_ult_check_length_range_known(i32* %array, i32* %length.ptr, i32 %n) { 278; CHECK-LABEL: @signed_loop_0_to_n_ult_check_length_range_known( 279; CHECK-NEXT: entry: 280; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0 281; CHECK-NEXT: [[LENGTH:%.*]] = load i32, i32* [[LENGTH_PTR:%.*]], !range !2 282; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 283; CHECK: loop.preheader: 284; CHECK-NEXT: [[TMP0:%.*]] = icmp sle i32 [[N]], [[LENGTH]] 285; CHECK-NEXT: [[TMP1:%.*]] = and i1 true, [[TMP0]] 286; CHECK-NEXT: br label [[LOOP:%.*]] 287; CHECK: loop: 288; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 289; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 290; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 291; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[WIDENABLE_COND]] 292; CHECK-NEXT: br i1 [[TMP2]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 293; CHECK: deopt: 294; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 295; CHECK-NEXT: ret i32 [[DEOPTCALL]] 296; CHECK: guarded: 297; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 298; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 299; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 300; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 301; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1 302; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]] 303; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 304; CHECK: exit.loopexit: 305; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 306; CHECK-NEXT: br label [[EXIT]] 307; CHECK: exit: 308; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 309; CHECK-NEXT: ret i32 [[RESULT]] 310; 311entry: 312 %tmp5 = icmp sle i32 %n, 0 313 %length = load i32, i32* %length.ptr, !range !1 314 br i1 %tmp5, label %exit, label %loop.preheader 315 316loop.preheader: ; preds = %entry 317 br label %loop 318 319loop: ; preds = %guarded, %loop.preheader 320 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 321 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 322 %within.bounds = icmp ult i32 %i, %length 323 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 324 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 325 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 326 327deopt: ; preds = %loop 328 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 329 ret i32 %deoptcall 330 331guarded: ; preds = %loop 332 %i.i64 = zext i32 %i to i64 333 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 334 %array.i = load i32, i32* %array.i.ptr, align 4 335 %loop.acc.next = add i32 %loop.acc, %array.i 336 %i.next = add nuw i32 %i, 1 337 %continue = icmp slt i32 %i.next, %n 338 br i1 %continue, label %loop, label %exit, !prof !2 339 340exit: ; preds = %guarded, %entry 341 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 342 ret i32 %result 343} 344 345define i32 @signed_loop_0_to_n_inverse_latch_predicate(i32* %array, i32 %length, i32 %n) { 346; CHECK-LABEL: @signed_loop_0_to_n_inverse_latch_predicate( 347; CHECK-NEXT: entry: 348; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0 349; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 350; CHECK: loop.preheader: 351; CHECK-NEXT: [[TMP0:%.*]] = icmp slt i32 [[N]], [[LENGTH:%.*]] 352; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]] 353; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]] 354; CHECK-NEXT: br label [[LOOP:%.*]] 355; CHECK: loop: 356; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 357; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 358; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 359; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]] 360; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 361; CHECK: deopt: 362; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 363; CHECK-NEXT: ret i32 [[DEOPTCALL]] 364; CHECK: guarded: 365; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 366; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 367; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 368; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 369; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1 370; CHECK-NEXT: [[CONTINUE:%.*]] = icmp sgt i32 [[I_NEXT]], [[N]] 371; CHECK-NEXT: br i1 [[CONTINUE]], label [[EXIT_LOOPEXIT:%.*]], label [[LOOP]], !prof !1 372; CHECK: exit.loopexit: 373; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 374; CHECK-NEXT: br label [[EXIT]] 375; CHECK: exit: 376; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 377; CHECK-NEXT: ret i32 [[RESULT]] 378; 379entry: 380 %tmp5 = icmp sle i32 %n, 0 381 br i1 %tmp5, label %exit, label %loop.preheader 382 383loop.preheader: ; preds = %entry 384 br label %loop 385 386loop: ; preds = %guarded, %loop.preheader 387 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 388 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 389 %within.bounds = icmp ult i32 %i, %length 390 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 391 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 392 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 393 394deopt: ; preds = %loop 395 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 396 ret i32 %deoptcall 397 398guarded: ; preds = %loop 399 %i.i64 = zext i32 %i to i64 400 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 401 %array.i = load i32, i32* %array.i.ptr, align 4 402 %loop.acc.next = add i32 %loop.acc, %array.i 403 %i.next = add nuw i32 %i, 1 404 %continue = icmp sgt i32 %i.next, %n 405 br i1 %continue, label %exit, label %loop, !prof !2 406 407exit: ; preds = %guarded, %entry 408 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 409 ret i32 %result 410} 411 412define i32 @signed_loop_0_to_n_sle_latch_ult_check(i32* %array, i32 %length, i32 %n) { 413; CHECK-LABEL: @signed_loop_0_to_n_sle_latch_ult_check( 414; CHECK-NEXT: entry: 415; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0 416; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 417; CHECK: loop.preheader: 418; CHECK-NEXT: [[TMP0:%.*]] = icmp slt i32 [[N]], [[LENGTH:%.*]] 419; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]] 420; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]] 421; CHECK-NEXT: br label [[LOOP:%.*]] 422; CHECK: loop: 423; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 424; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 425; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 426; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]] 427; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 428; CHECK: deopt: 429; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 430; CHECK-NEXT: ret i32 [[DEOPTCALL]] 431; CHECK: guarded: 432; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 433; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 434; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 435; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 436; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1 437; CHECK-NEXT: [[CONTINUE:%.*]] = icmp sle i32 [[I_NEXT]], [[N]] 438; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 439; CHECK: exit.loopexit: 440; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 441; CHECK-NEXT: br label [[EXIT]] 442; CHECK: exit: 443; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 444; CHECK-NEXT: ret i32 [[RESULT]] 445; 446entry: 447 %tmp5 = icmp sle i32 %n, 0 448 br i1 %tmp5, label %exit, label %loop.preheader 449 450loop.preheader: ; preds = %entry 451 br label %loop 452 453loop: ; preds = %guarded, %loop.preheader 454 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 455 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 456 %within.bounds = icmp ult i32 %i, %length 457 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 458 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 459 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 460 461deopt: ; preds = %loop 462 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 463 ret i32 %deoptcall 464 465guarded: ; preds = %loop 466 %i.i64 = zext i32 %i to i64 467 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 468 %array.i = load i32, i32* %array.i.ptr, align 4 469 %loop.acc.next = add i32 %loop.acc, %array.i 470 %i.next = add nuw i32 %i, 1 471 %continue = icmp sle i32 %i.next, %n 472 br i1 %continue, label %loop, label %exit, !prof !2 473 474exit: ; preds = %guarded, %entry 475 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 476 ret i32 %result 477} 478 479define i32 @signed_loop_0_to_n_preincrement_latch_check(i32* %array, i32 %length, i32 %n) { 480; CHECK-LABEL: @signed_loop_0_to_n_preincrement_latch_check( 481; CHECK-NEXT: entry: 482; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0 483; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 484; CHECK: loop.preheader: 485; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[LENGTH:%.*]], -1 486; CHECK-NEXT: [[TMP1:%.*]] = icmp sle i32 [[N]], [[TMP0]] 487; CHECK-NEXT: [[TMP2:%.*]] = icmp ult i32 0, [[LENGTH]] 488; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[TMP1]] 489; CHECK-NEXT: br label [[LOOP:%.*]] 490; CHECK: loop: 491; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 492; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 493; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 494; CHECK-NEXT: [[TMP4:%.*]] = and i1 [[TMP3]], [[WIDENABLE_COND]] 495; CHECK-NEXT: br i1 [[TMP4]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 496; CHECK: deopt: 497; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 498; CHECK-NEXT: ret i32 [[DEOPTCALL]] 499; CHECK: guarded: 500; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 501; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 502; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 503; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 504; CHECK-NEXT: [[I_NEXT]] = add i32 [[I]], 1 505; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I]], [[N]] 506; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 507; CHECK: exit.loopexit: 508; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 509; CHECK-NEXT: br label [[EXIT]] 510; CHECK: exit: 511; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 512; CHECK-NEXT: ret i32 [[RESULT]] 513; 514entry: 515 %tmp5 = icmp sle i32 %n, 0 516 br i1 %tmp5, label %exit, label %loop.preheader 517 518loop.preheader: ; preds = %entry 519 br label %loop 520 521loop: ; preds = %guarded, %loop.preheader 522 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 523 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 524 %within.bounds = icmp ult i32 %i, %length 525 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 526 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 527 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 528 529deopt: ; preds = %loop 530 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 531 ret i32 %deoptcall 532 533guarded: ; preds = %loop 534 %i.i64 = zext i32 %i to i64 535 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 536 %array.i = load i32, i32* %array.i.ptr, align 4 537 %loop.acc.next = add i32 %loop.acc, %array.i 538 %i.next = add i32 %i, 1 539 %continue = icmp slt i32 %i, %n 540 br i1 %continue, label %loop, label %exit, !prof !2 541 542exit: ; preds = %guarded, %entry 543 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 544 ret i32 %result 545} 546 547define i32 @signed_loop_0_to_n_preincrement_latch_check_postincrement_guard_check(i32* %array, i32 %length, i32 %n) { 548; CHECK-LABEL: @signed_loop_0_to_n_preincrement_latch_check_postincrement_guard_check( 549; CHECK-NEXT: entry: 550; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0 551; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 552; CHECK: loop.preheader: 553; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[LENGTH:%.*]], -2 554; CHECK-NEXT: [[TMP1:%.*]] = icmp sle i32 [[N]], [[TMP0]] 555; CHECK-NEXT: [[TMP2:%.*]] = icmp ult i32 1, [[LENGTH]] 556; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[TMP1]] 557; CHECK-NEXT: br label [[LOOP:%.*]] 558; CHECK: loop: 559; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 560; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 561; CHECK-NEXT: [[I_NEXT]] = add i32 [[I]], 1 562; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 563; CHECK-NEXT: [[TMP4:%.*]] = and i1 [[TMP3]], [[WIDENABLE_COND]] 564; CHECK-NEXT: br i1 [[TMP4]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 565; CHECK: deopt: 566; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 567; CHECK-NEXT: ret i32 [[DEOPTCALL]] 568; CHECK: guarded: 569; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 570; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 571; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 572; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 573; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I]], [[N]] 574; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 575; CHECK: exit.loopexit: 576; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 577; CHECK-NEXT: br label [[EXIT]] 578; CHECK: exit: 579; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 580; CHECK-NEXT: ret i32 [[RESULT]] 581; 582entry: 583 %tmp5 = icmp sle i32 %n, 0 584 br i1 %tmp5, label %exit, label %loop.preheader 585 586loop.preheader: ; preds = %entry 587 br label %loop 588 589loop: ; preds = %guarded, %loop.preheader 590 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 591 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 592 %i.next = add i32 %i, 1 593 %within.bounds = icmp ult i32 %i.next, %length 594 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 595 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 596 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 597 598deopt: ; preds = %loop 599 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 600 ret i32 %deoptcall 601 602guarded: ; preds = %loop 603 %i.i64 = zext i32 %i to i64 604 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 605 %array.i = load i32, i32* %array.i.ptr, align 4 606 %loop.acc.next = add i32 %loop.acc, %array.i 607 %continue = icmp slt i32 %i, %n 608 br i1 %continue, label %loop, label %exit, !prof !2 609 610exit: ; preds = %guarded, %entry 611 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 612 ret i32 %result 613} 614 615define i32 @signed_loop_0_to_n_sle_latch_offset_ult_check(i32* %array, i32 %length, i32 %n) { 616; CHECK-LABEL: @signed_loop_0_to_n_sle_latch_offset_ult_check( 617; CHECK-NEXT: entry: 618; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0 619; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 620; CHECK: loop.preheader: 621; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[LENGTH:%.*]], -1 622; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[N]], [[TMP0]] 623; CHECK-NEXT: [[TMP2:%.*]] = icmp ult i32 1, [[LENGTH]] 624; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[TMP1]] 625; CHECK-NEXT: br label [[LOOP:%.*]] 626; CHECK: loop: 627; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 628; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 629; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 630; CHECK-NEXT: [[TMP4:%.*]] = and i1 [[TMP3]], [[WIDENABLE_COND]] 631; CHECK-NEXT: br i1 [[TMP4]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 632; CHECK: deopt: 633; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 634; CHECK-NEXT: ret i32 [[DEOPTCALL]] 635; CHECK: guarded: 636; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 637; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 638; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 639; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 640; CHECK-NEXT: [[I_NEXT]] = add i32 [[I]], 1 641; CHECK-NEXT: [[CONTINUE:%.*]] = icmp sle i32 [[I_NEXT]], [[N]] 642; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 643; CHECK: exit.loopexit: 644; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 645; CHECK-NEXT: br label [[EXIT]] 646; CHECK: exit: 647; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 648; CHECK-NEXT: ret i32 [[RESULT]] 649; 650entry: 651 %tmp5 = icmp sle i32 %n, 0 652 br i1 %tmp5, label %exit, label %loop.preheader 653 654loop.preheader: ; preds = %entry 655 br label %loop 656 657loop: ; preds = %guarded, %loop.preheader 658 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 659 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 660 %i.offset = add i32 %i, 1 661 %within.bounds = icmp ult i32 %i.offset, %length 662 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 663 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 664 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 665 666deopt: ; preds = %loop 667 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 668 ret i32 %deoptcall 669 670guarded: ; preds = %loop 671 %i.i64 = zext i32 %i to i64 672 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 673 %array.i = load i32, i32* %array.i.ptr, align 4 674 %loop.acc.next = add i32 %loop.acc, %array.i 675 %i.next = add i32 %i, 1 676 %continue = icmp sle i32 %i.next, %n 677 br i1 %continue, label %loop, label %exit, !prof !2 678 679exit: ; preds = %guarded, %entry 680 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 681 ret i32 %result 682} 683 684define i32 @signed_loop_0_to_n_offset_sle_latch_offset_ult_check(i32* %array, i32 %length, i32 %n) { 685; CHECK-LABEL: @signed_loop_0_to_n_offset_sle_latch_offset_ult_check( 686; CHECK-NEXT: entry: 687; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0 688; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 689; CHECK: loop.preheader: 690; CHECK-NEXT: [[TMP0:%.*]] = icmp slt i32 [[N]], [[LENGTH:%.*]] 691; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 1, [[LENGTH]] 692; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]] 693; CHECK-NEXT: br label [[LOOP:%.*]] 694; CHECK: loop: 695; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 696; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 697; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 698; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]] 699; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 700; CHECK: deopt: 701; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 702; CHECK-NEXT: ret i32 [[DEOPTCALL]] 703; CHECK: guarded: 704; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 705; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 706; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 707; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 708; CHECK-NEXT: [[I_NEXT]] = add i32 [[I]], 1 709; CHECK-NEXT: [[I_NEXT_OFFSET:%.*]] = add i32 [[I_NEXT]], 1 710; CHECK-NEXT: [[CONTINUE:%.*]] = icmp sle i32 [[I_NEXT_OFFSET]], [[N]] 711; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 712; CHECK: exit.loopexit: 713; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 714; CHECK-NEXT: br label [[EXIT]] 715; CHECK: exit: 716; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 717; CHECK-NEXT: ret i32 [[RESULT]] 718; 719entry: 720 %tmp5 = icmp sle i32 %n, 0 721 br i1 %tmp5, label %exit, label %loop.preheader 722 723loop.preheader: ; preds = %entry 724 br label %loop 725 726loop: ; preds = %guarded, %loop.preheader 727 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 728 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 729 %i.offset = add i32 %i, 1 730 %within.bounds = icmp ult i32 %i.offset, %length 731 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 732 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 733 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 734 735deopt: ; preds = %loop 736 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 737 ret i32 %deoptcall 738 739guarded: ; preds = %loop 740 %i.i64 = zext i32 %i to i64 741 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 742 %array.i = load i32, i32* %array.i.ptr, align 4 743 %loop.acc.next = add i32 %loop.acc, %array.i 744 %i.next = add i32 %i, 1 745 %i.next.offset = add i32 %i.next, 1 746 %continue = icmp sle i32 %i.next.offset, %n 747 br i1 %continue, label %loop, label %exit, !prof !2 748 749exit: ; preds = %guarded, %entry 750 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 751 ret i32 %result 752} 753 754define i32 @unsupported_latch_pred_loop_0_to_n(i32* %array, i32 %length, i32 %n) { 755; CHECK-LABEL: @unsupported_latch_pred_loop_0_to_n( 756; CHECK-NEXT: entry: 757; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0 758; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 759; CHECK: loop.preheader: 760; CHECK-NEXT: br label [[LOOP:%.*]] 761; CHECK: loop: 762; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 763; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 764; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i32 [[I]], [[LENGTH:%.*]] 765; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 766; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[WITHIN_BOUNDS]], [[WIDENABLE_COND]] 767; CHECK-NEXT: br i1 [[EXIPLICIT_GUARD_COND]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 768; CHECK: deopt: 769; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 770; CHECK-NEXT: ret i32 [[DEOPTCALL]] 771; CHECK: guarded: 772; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 773; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 774; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 775; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 776; CHECK-NEXT: [[I_NEXT]] = add nsw i32 [[I]], 1 777; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ne i32 [[I_NEXT]], [[N]] 778; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 779; CHECK: exit.loopexit: 780; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 781; CHECK-NEXT: br label [[EXIT]] 782; CHECK: exit: 783; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 784; CHECK-NEXT: ret i32 [[RESULT]] 785; 786entry: 787 %tmp5 = icmp sle i32 %n, 0 788 br i1 %tmp5, label %exit, label %loop.preheader 789 790loop.preheader: ; preds = %entry 791 br label %loop 792 793loop: ; preds = %guarded, %loop.preheader 794 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 795 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 796 %within.bounds = icmp ult i32 %i, %length 797 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 798 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 799 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 800 801deopt: ; preds = %loop 802 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 803 ret i32 %deoptcall 804 805guarded: ; preds = %loop 806 %i.i64 = zext i32 %i to i64 807 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 808 %array.i = load i32, i32* %array.i.ptr, align 4 809 %loop.acc.next = add i32 %loop.acc, %array.i 810 %i.next = add nsw i32 %i, 1 811 %continue = icmp ne i32 %i.next, %n 812 br i1 %continue, label %loop, label %exit, !prof !2 813 814exit: ; preds = %guarded, %entry 815 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 816 ret i32 %result 817} 818 819define i32 @signed_loop_0_to_n_unsupported_iv_step(i32* %array, i32 %length, i32 %n) { 820; CHECK-LABEL: @signed_loop_0_to_n_unsupported_iv_step( 821; CHECK-NEXT: entry: 822; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0 823; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 824; CHECK: loop.preheader: 825; CHECK-NEXT: br label [[LOOP:%.*]] 826; CHECK: loop: 827; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 828; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 829; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i32 [[I]], [[LENGTH:%.*]] 830; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 831; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[WITHIN_BOUNDS]], [[WIDENABLE_COND]] 832; CHECK-NEXT: br i1 [[EXIPLICIT_GUARD_COND]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 833; CHECK: deopt: 834; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 835; CHECK-NEXT: ret i32 [[DEOPTCALL]] 836; CHECK: guarded: 837; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 838; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 839; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 840; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 841; CHECK-NEXT: [[I_NEXT]] = add nsw i32 [[I]], 2 842; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]] 843; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 844; CHECK: exit.loopexit: 845; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 846; CHECK-NEXT: br label [[EXIT]] 847; CHECK: exit: 848; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 849; CHECK-NEXT: ret i32 [[RESULT]] 850; 851entry: 852 %tmp5 = icmp sle i32 %n, 0 853 br i1 %tmp5, label %exit, label %loop.preheader 854 855loop.preheader: ; preds = %entry 856 br label %loop 857 858loop: ; preds = %guarded, %loop.preheader 859 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 860 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 861 %within.bounds = icmp ult i32 %i, %length 862 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 863 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 864 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 865 866deopt: ; preds = %loop 867 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 868 ret i32 %deoptcall 869 870guarded: ; preds = %loop 871 %i.i64 = zext i32 %i to i64 872 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 873 %array.i = load i32, i32* %array.i.ptr, align 4 874 %loop.acc.next = add i32 %loop.acc, %array.i 875 %i.next = add nsw i32 %i, 2 876 %continue = icmp slt i32 %i.next, %n 877 br i1 %continue, label %loop, label %exit, !prof !2 878 879exit: ; preds = %guarded, %entry 880 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 881 ret i32 %result 882} 883 884define i32 @signed_loop_0_to_n_equal_iv_range_check(i32* %array, i32 %length, i32 %n) { 885; CHECK-LABEL: @signed_loop_0_to_n_equal_iv_range_check( 886; CHECK-NEXT: entry: 887; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0 888; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 889; CHECK: loop.preheader: 890; CHECK-NEXT: [[TMP0:%.*]] = icmp sle i32 [[N]], [[LENGTH:%.*]] 891; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]] 892; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]] 893; CHECK-NEXT: br label [[LOOP:%.*]] 894; CHECK: loop: 895; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 896; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 897; CHECK-NEXT: [[J:%.*]] = phi i32 [ [[J_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 898; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 899; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]] 900; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 901; CHECK: deopt: 902; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 903; CHECK-NEXT: ret i32 [[DEOPTCALL]] 904; CHECK: guarded: 905; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 906; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 907; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 908; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 909; CHECK-NEXT: [[J_NEXT]] = add nsw i32 [[J]], 1 910; CHECK-NEXT: [[I_NEXT]] = add nsw i32 [[I]], 1 911; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]] 912; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 913; CHECK: exit.loopexit: 914; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 915; CHECK-NEXT: br label [[EXIT]] 916; CHECK: exit: 917; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 918; CHECK-NEXT: ret i32 [[RESULT]] 919; 920entry: 921 %tmp5 = icmp sle i32 %n, 0 922 br i1 %tmp5, label %exit, label %loop.preheader 923 924loop.preheader: ; preds = %entry 925 br label %loop 926 927loop: ; preds = %guarded, %loop.preheader 928 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 929 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 930 %j = phi i32 [ %j.next, %guarded ], [ 0, %loop.preheader ] 931 %within.bounds = icmp ult i32 %j, %length 932 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 933 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 934 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 935 936deopt: ; preds = %loop 937 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 938 ret i32 %deoptcall 939 940guarded: ; preds = %loop 941 %i.i64 = zext i32 %i to i64 942 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 943 %array.i = load i32, i32* %array.i.ptr, align 4 944 %loop.acc.next = add i32 %loop.acc, %array.i 945 %j.next = add nsw i32 %j, 1 946 %i.next = add nsw i32 %i, 1 947 %continue = icmp slt i32 %i.next, %n 948 br i1 %continue, label %loop, label %exit, !prof !2 949 950exit: ; preds = %guarded, %entry 951 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 952 ret i32 %result 953} 954 955define i32 @signed_loop_start_to_n_offset_iv_range_check(i32* %array, i32 %start.i, i32 %start.j, i32 %length, i32 %n) { 956; CHECK-LABEL: @signed_loop_start_to_n_offset_iv_range_check( 957; CHECK-NEXT: entry: 958; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0 959; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 960; CHECK: loop.preheader: 961; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[LENGTH:%.*]], [[START_I:%.*]] 962; CHECK-NEXT: [[TMP1:%.*]] = sub i32 [[TMP0]], [[START_J:%.*]] 963; CHECK-NEXT: [[TMP2:%.*]] = icmp sle i32 [[N]], [[TMP1]] 964; CHECK-NEXT: [[TMP3:%.*]] = icmp ult i32 [[START_J]], [[LENGTH]] 965; CHECK-NEXT: [[TMP4:%.*]] = and i1 [[TMP3]], [[TMP2]] 966; CHECK-NEXT: br label [[LOOP:%.*]] 967; CHECK: loop: 968; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 969; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ [[START_I]], [[LOOP_PREHEADER]] ] 970; CHECK-NEXT: [[J:%.*]] = phi i32 [ [[J_NEXT:%.*]], [[GUARDED]] ], [ [[START_J]], [[LOOP_PREHEADER]] ] 971; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 972; CHECK-NEXT: [[TMP5:%.*]] = and i1 [[TMP4]], [[WIDENABLE_COND]] 973; CHECK-NEXT: br i1 [[TMP5]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 974; CHECK: deopt: 975; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 976; CHECK-NEXT: ret i32 [[DEOPTCALL]] 977; CHECK: guarded: 978; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 979; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 980; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 981; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 982; CHECK-NEXT: [[J_NEXT]] = add i32 [[J]], 1 983; CHECK-NEXT: [[I_NEXT]] = add i32 [[I]], 1 984; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]] 985; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 986; CHECK: exit.loopexit: 987; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 988; CHECK-NEXT: br label [[EXIT]] 989; CHECK: exit: 990; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 991; CHECK-NEXT: ret i32 [[RESULT]] 992; 993entry: 994 %tmp5 = icmp sle i32 %n, 0 995 br i1 %tmp5, label %exit, label %loop.preheader 996 997loop.preheader: ; preds = %entry 998 br label %loop 999 1000loop: ; preds = %guarded, %loop.preheader 1001 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 1002 %i = phi i32 [ %i.next, %guarded ], [ %start.i, %loop.preheader ] 1003 %j = phi i32 [ %j.next, %guarded ], [ %start.j, %loop.preheader ] 1004 %within.bounds = icmp ult i32 %j, %length 1005 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 1006 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 1007 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 1008 1009deopt: ; preds = %loop 1010 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1011 ret i32 %deoptcall 1012 1013guarded: ; preds = %loop 1014 %i.i64 = zext i32 %i to i64 1015 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 1016 %array.i = load i32, i32* %array.i.ptr, align 4 1017 %loop.acc.next = add i32 %loop.acc, %array.i 1018 %j.next = add i32 %j, 1 1019 %i.next = add i32 %i, 1 1020 %continue = icmp slt i32 %i.next, %n 1021 br i1 %continue, label %loop, label %exit, !prof !2 1022 1023exit: ; preds = %guarded, %entry 1024 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 1025 ret i32 %result 1026} 1027 1028define i32 @signed_loop_0_to_n_different_iv_types(i32* %array, i16 %length, i32 %n) { 1029; CHECK-LABEL: @signed_loop_0_to_n_different_iv_types( 1030; CHECK-NEXT: entry: 1031; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0 1032; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 1033; CHECK: loop.preheader: 1034; CHECK-NEXT: br label [[LOOP:%.*]] 1035; CHECK: loop: 1036; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 1037; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 1038; CHECK-NEXT: [[J:%.*]] = phi i16 [ [[J_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 1039; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i16 [[J]], [[LENGTH:%.*]] 1040; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 1041; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[WITHIN_BOUNDS]], [[WIDENABLE_COND]] 1042; CHECK-NEXT: br i1 [[EXIPLICIT_GUARD_COND]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 1043; CHECK: deopt: 1044; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1045; CHECK-NEXT: ret i32 [[DEOPTCALL]] 1046; CHECK: guarded: 1047; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 1048; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 1049; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 1050; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 1051; CHECK-NEXT: [[J_NEXT]] = add i16 [[J]], 1 1052; CHECK-NEXT: [[I_NEXT]] = add i32 [[I]], 1 1053; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]] 1054; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 1055; CHECK: exit.loopexit: 1056; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 1057; CHECK-NEXT: br label [[EXIT]] 1058; CHECK: exit: 1059; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 1060; CHECK-NEXT: ret i32 [[RESULT]] 1061; 1062entry: 1063 %tmp5 = icmp sle i32 %n, 0 1064 br i1 %tmp5, label %exit, label %loop.preheader 1065 1066loop.preheader: ; preds = %entry 1067 br label %loop 1068 1069loop: ; preds = %guarded, %loop.preheader 1070 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 1071 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 1072 %j = phi i16 [ %j.next, %guarded ], [ 0, %loop.preheader ] 1073 %within.bounds = icmp ult i16 %j, %length 1074 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 1075 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 1076 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 1077 1078deopt: ; preds = %loop 1079 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1080 ret i32 %deoptcall 1081 1082guarded: ; preds = %loop 1083 %i.i64 = zext i32 %i to i64 1084 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 1085 %array.i = load i32, i32* %array.i.ptr, align 4 1086 %loop.acc.next = add i32 %loop.acc, %array.i 1087 %j.next = add i16 %j, 1 1088 %i.next = add i32 %i, 1 1089 %continue = icmp slt i32 %i.next, %n 1090 br i1 %continue, label %loop, label %exit, !prof !2 1091 1092exit: ; preds = %guarded, %entry 1093 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 1094 ret i32 %result 1095} 1096 1097define i32 @signed_loop_0_to_n_different_iv_strides(i32* %array, i32 %length, i32 %n) { 1098; CHECK-LABEL: @signed_loop_0_to_n_different_iv_strides( 1099; CHECK-NEXT: entry: 1100; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0 1101; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 1102; CHECK: loop.preheader: 1103; CHECK-NEXT: br label [[LOOP:%.*]] 1104; CHECK: loop: 1105; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 1106; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 1107; CHECK-NEXT: [[J:%.*]] = phi i32 [ [[J_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 1108; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i32 [[J]], [[LENGTH:%.*]] 1109; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 1110; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[WITHIN_BOUNDS]], [[WIDENABLE_COND]] 1111; CHECK-NEXT: br i1 [[EXIPLICIT_GUARD_COND]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 1112; CHECK: deopt: 1113; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1114; CHECK-NEXT: ret i32 [[DEOPTCALL]] 1115; CHECK: guarded: 1116; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 1117; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 1118; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 1119; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 1120; CHECK-NEXT: [[J_NEXT]] = add nsw i32 [[J]], 2 1121; CHECK-NEXT: [[I_NEXT]] = add nsw i32 [[I]], 1 1122; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]] 1123; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 1124; CHECK: exit.loopexit: 1125; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 1126; CHECK-NEXT: br label [[EXIT]] 1127; CHECK: exit: 1128; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 1129; CHECK-NEXT: ret i32 [[RESULT]] 1130; 1131entry: 1132 %tmp5 = icmp sle i32 %n, 0 1133 br i1 %tmp5, label %exit, label %loop.preheader 1134 1135loop.preheader: ; preds = %entry 1136 br label %loop 1137 1138loop: ; preds = %guarded, %loop.preheader 1139 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 1140 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 1141 %j = phi i32 [ %j.next, %guarded ], [ 0, %loop.preheader ] 1142 %within.bounds = icmp ult i32 %j, %length 1143 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 1144 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 1145 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 1146 1147deopt: ; preds = %loop 1148 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1149 ret i32 %deoptcall 1150 1151guarded: ; preds = %loop 1152 %i.i64 = zext i32 %i to i64 1153 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 1154 %array.i = load i32, i32* %array.i.ptr, align 4 1155 %loop.acc.next = add i32 %loop.acc, %array.i 1156 %j.next = add nsw i32 %j, 2 1157 %i.next = add nsw i32 %i, 1 1158 %continue = icmp slt i32 %i.next, %n 1159 br i1 %continue, label %loop, label %exit, !prof !2 1160 1161exit: ; preds = %guarded, %entry 1162 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 1163 ret i32 %result 1164} 1165 1166define i32 @two_range_checks(i32* %array.1, i32 %length.1, i32* %array.2, i32 %length.2, i32 %n) { 1167; CHECK-LABEL: @two_range_checks( 1168; CHECK-NEXT: entry: 1169; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0 1170; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 1171; CHECK: loop.preheader: 1172; CHECK-NEXT: [[TMP0:%.*]] = icmp ule i32 [[N]], [[LENGTH_2:%.*]] 1173; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH_2]] 1174; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]] 1175; CHECK-NEXT: [[TMP3:%.*]] = icmp ule i32 [[N]], [[LENGTH_1:%.*]] 1176; CHECK-NEXT: [[TMP4:%.*]] = icmp ult i32 0, [[LENGTH_1]] 1177; CHECK-NEXT: [[TMP5:%.*]] = and i1 [[TMP4]], [[TMP3]] 1178; CHECK-NEXT: br label [[LOOP:%.*]] 1179; CHECK: loop: 1180; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 1181; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 1182; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 1183; CHECK-NEXT: [[TMP6:%.*]] = and i1 [[TMP2]], [[TMP5]] 1184; CHECK-NEXT: [[TMP7:%.*]] = and i1 [[TMP6]], [[WIDENABLE_COND]] 1185; CHECK-NEXT: br i1 [[TMP7]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 1186; CHECK: deopt: 1187; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1188; CHECK-NEXT: ret i32 [[DEOPTCALL]] 1189; CHECK: guarded: 1190; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 1191; CHECK-NEXT: [[ARRAY_1_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY_1:%.*]], i64 [[I_I64]] 1192; CHECK-NEXT: [[ARRAY_1_I:%.*]] = load i32, i32* [[ARRAY_1_I_PTR]], align 4 1193; CHECK-NEXT: [[LOOP_ACC_1:%.*]] = add i32 [[LOOP_ACC]], [[ARRAY_1_I]] 1194; CHECK-NEXT: [[ARRAY_2_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY_2:%.*]], i64 [[I_I64]] 1195; CHECK-NEXT: [[ARRAY_2_I:%.*]] = load i32, i32* [[ARRAY_2_I_PTR]], align 4 1196; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC_1]], [[ARRAY_2_I]] 1197; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1 1198; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]] 1199; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 1200; CHECK: exit.loopexit: 1201; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 1202; CHECK-NEXT: br label [[EXIT]] 1203; CHECK: exit: 1204; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 1205; CHECK-NEXT: ret i32 [[RESULT]] 1206; 1207entry: 1208 %tmp5 = icmp eq i32 %n, 0 1209 br i1 %tmp5, label %exit, label %loop.preheader 1210 1211loop.preheader: ; preds = %entry 1212 br label %loop 1213 1214loop: ; preds = %guarded, %loop.preheader 1215 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 1216 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 1217 %within.bounds.1 = icmp ult i32 %i, %length.1 1218 %within.bounds.2 = icmp ult i32 %i, %length.2 1219 %within.bounds = and i1 %within.bounds.1, %within.bounds.2 1220 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 1221 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 1222 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 1223 1224deopt: ; preds = %loop 1225 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1226 ret i32 %deoptcall 1227 1228guarded: ; preds = %loop 1229 %i.i64 = zext i32 %i to i64 1230 %array.1.i.ptr = getelementptr inbounds i32, i32* %array.1, i64 %i.i64 1231 %array.1.i = load i32, i32* %array.1.i.ptr, align 4 1232 %loop.acc.1 = add i32 %loop.acc, %array.1.i 1233 %array.2.i.ptr = getelementptr inbounds i32, i32* %array.2, i64 %i.i64 1234 %array.2.i = load i32, i32* %array.2.i.ptr, align 4 1235 %loop.acc.next = add i32 %loop.acc.1, %array.2.i 1236 %i.next = add nuw i32 %i, 1 1237 %continue = icmp ult i32 %i.next, %n 1238 br i1 %continue, label %loop, label %exit, !prof !2 1239 1240exit: ; preds = %guarded, %entry 1241 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 1242 ret i32 %result 1243} 1244 1245define i32 @three_range_checks(i32* %array.1, i32 %length.1, i32* %array.2, i32 %length.2, i32* %array.3, i32 %length.3, i32 %n) { 1246; CHECK-LABEL: @three_range_checks( 1247; CHECK-NEXT: entry: 1248; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0 1249; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 1250; CHECK: loop.preheader: 1251; CHECK-NEXT: [[TMP0:%.*]] = icmp ule i32 [[N]], [[LENGTH_3:%.*]] 1252; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH_3]] 1253; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]] 1254; CHECK-NEXT: [[TMP3:%.*]] = icmp ule i32 [[N]], [[LENGTH_2:%.*]] 1255; CHECK-NEXT: [[TMP4:%.*]] = icmp ult i32 0, [[LENGTH_2]] 1256; CHECK-NEXT: [[TMP5:%.*]] = and i1 [[TMP4]], [[TMP3]] 1257; CHECK-NEXT: [[TMP6:%.*]] = icmp ule i32 [[N]], [[LENGTH_1:%.*]] 1258; CHECK-NEXT: [[TMP7:%.*]] = icmp ult i32 0, [[LENGTH_1]] 1259; CHECK-NEXT: [[TMP8:%.*]] = and i1 [[TMP7]], [[TMP6]] 1260; CHECK-NEXT: br label [[LOOP:%.*]] 1261; CHECK: loop: 1262; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 1263; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 1264; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 1265; CHECK-NEXT: [[TMP9:%.*]] = and i1 [[TMP2]], [[TMP5]] 1266; CHECK-NEXT: [[TMP10:%.*]] = and i1 [[TMP9]], [[TMP8]] 1267; CHECK-NEXT: [[TMP11:%.*]] = and i1 [[TMP10]], [[WIDENABLE_COND]] 1268; CHECK-NEXT: br i1 [[TMP11]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 1269; CHECK: deopt: 1270; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1271; CHECK-NEXT: ret i32 [[DEOPTCALL]] 1272; CHECK: guarded: 1273; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 1274; CHECK-NEXT: [[ARRAY_1_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY_1:%.*]], i64 [[I_I64]] 1275; CHECK-NEXT: [[ARRAY_1_I:%.*]] = load i32, i32* [[ARRAY_1_I_PTR]], align 4 1276; CHECK-NEXT: [[LOOP_ACC_1:%.*]] = add i32 [[LOOP_ACC]], [[ARRAY_1_I]] 1277; CHECK-NEXT: [[ARRAY_2_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY_2:%.*]], i64 [[I_I64]] 1278; CHECK-NEXT: [[ARRAY_2_I:%.*]] = load i32, i32* [[ARRAY_2_I_PTR]], align 4 1279; CHECK-NEXT: [[LOOP_ACC_2:%.*]] = add i32 [[LOOP_ACC_1]], [[ARRAY_2_I]] 1280; CHECK-NEXT: [[ARRAY_3_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY_3:%.*]], i64 [[I_I64]] 1281; CHECK-NEXT: [[ARRAY_3_I:%.*]] = load i32, i32* [[ARRAY_3_I_PTR]], align 4 1282; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC_2]], [[ARRAY_3_I]] 1283; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1 1284; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]] 1285; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 1286; CHECK: exit.loopexit: 1287; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 1288; CHECK-NEXT: br label [[EXIT]] 1289; CHECK: exit: 1290; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 1291; CHECK-NEXT: ret i32 [[RESULT]] 1292; 1293entry: 1294 %tmp5 = icmp eq i32 %n, 0 1295 br i1 %tmp5, label %exit, label %loop.preheader 1296 1297loop.preheader: ; preds = %entry 1298 br label %loop 1299 1300loop: ; preds = %guarded, %loop.preheader 1301 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 1302 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 1303 %within.bounds.1 = icmp ult i32 %i, %length.1 1304 %within.bounds.2 = icmp ult i32 %i, %length.2 1305 %within.bounds.3 = icmp ult i32 %i, %length.3 1306 %within.bounds.1.and.2 = and i1 %within.bounds.1, %within.bounds.2 1307 %within.bounds = and i1 %within.bounds.1.and.2, %within.bounds.3 1308 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 1309 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 1310 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 1311 1312deopt: ; preds = %loop 1313 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1314 ret i32 %deoptcall 1315 1316guarded: ; preds = %loop 1317 %i.i64 = zext i32 %i to i64 1318 %array.1.i.ptr = getelementptr inbounds i32, i32* %array.1, i64 %i.i64 1319 %array.1.i = load i32, i32* %array.1.i.ptr, align 4 1320 %loop.acc.1 = add i32 %loop.acc, %array.1.i 1321 %array.2.i.ptr = getelementptr inbounds i32, i32* %array.2, i64 %i.i64 1322 %array.2.i = load i32, i32* %array.2.i.ptr, align 4 1323 %loop.acc.2 = add i32 %loop.acc.1, %array.2.i 1324 %array.3.i.ptr = getelementptr inbounds i32, i32* %array.3, i64 %i.i64 1325 %array.3.i = load i32, i32* %array.3.i.ptr, align 4 1326 %loop.acc.next = add i32 %loop.acc.2, %array.3.i 1327 %i.next = add nuw i32 %i, 1 1328 %continue = icmp ult i32 %i.next, %n 1329 br i1 %continue, label %loop, label %exit, !prof !2 1330 1331exit: ; preds = %guarded, %entry 1332 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 1333 ret i32 %result 1334} 1335 1336define i32 @three_guards(i32* %array.1, i32 %length.1, i32* %array.2, i32 %length.2, i32* %array.3, i32 %length.3, i32 %n) { 1337; CHECK-LABEL: @three_guards( 1338; CHECK-NEXT: entry: 1339; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0 1340; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 1341; CHECK: loop.preheader: 1342; CHECK-NEXT: [[TMP0:%.*]] = icmp ule i32 [[N]], [[LENGTH_1:%.*]] 1343; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH_1]] 1344; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]] 1345; CHECK-NEXT: [[TMP3:%.*]] = icmp ule i32 [[N]], [[LENGTH_2:%.*]] 1346; CHECK-NEXT: [[TMP4:%.*]] = icmp ult i32 0, [[LENGTH_2]] 1347; CHECK-NEXT: [[TMP5:%.*]] = and i1 [[TMP4]], [[TMP3]] 1348; CHECK-NEXT: [[TMP6:%.*]] = icmp ule i32 [[N]], [[LENGTH_3:%.*]] 1349; CHECK-NEXT: [[TMP7:%.*]] = icmp ult i32 0, [[LENGTH_3]] 1350; CHECK-NEXT: [[TMP8:%.*]] = and i1 [[TMP7]], [[TMP6]] 1351; CHECK-NEXT: br label [[LOOP:%.*]] 1352; CHECK: loop: 1353; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED6:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 1354; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED6]] ], [ 0, [[LOOP_PREHEADER]] ] 1355; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 1356; CHECK-NEXT: [[TMP9:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]] 1357; CHECK-NEXT: br i1 [[TMP9]], label [[GUARDED:%.*]], label [[DEOPT:%.*]], !prof !0 1358; CHECK: deopt: 1359; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1360; CHECK-NEXT: ret i32 [[DEOPTCALL]] 1361; CHECK: guarded: 1362; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 1363; CHECK-NEXT: [[ARRAY_1_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY_1:%.*]], i64 [[I_I64]] 1364; CHECK-NEXT: [[ARRAY_1_I:%.*]] = load i32, i32* [[ARRAY_1_I_PTR]], align 4 1365; CHECK-NEXT: [[LOOP_ACC_1:%.*]] = add i32 [[LOOP_ACC]], [[ARRAY_1_I]] 1366; CHECK-NEXT: [[WIDENABLE_COND4:%.*]] = call i1 @llvm.experimental.widenable.condition() 1367; CHECK-NEXT: [[TMP10:%.*]] = and i1 [[TMP5]], [[WIDENABLE_COND4]] 1368; CHECK-NEXT: br i1 [[TMP10]], label [[GUARDED1:%.*]], label [[DEOPT2:%.*]], !prof !0 1369; CHECK: deopt2: 1370; CHECK-NEXT: [[DEOPTCALL3:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1371; CHECK-NEXT: ret i32 [[DEOPTCALL3]] 1372; CHECK: guarded1: 1373; CHECK-NEXT: [[ARRAY_2_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY_2:%.*]], i64 [[I_I64]] 1374; CHECK-NEXT: [[ARRAY_2_I:%.*]] = load i32, i32* [[ARRAY_2_I_PTR]], align 4 1375; CHECK-NEXT: [[LOOP_ACC_2:%.*]] = add i32 [[LOOP_ACC_1]], [[ARRAY_2_I]] 1376; CHECK-NEXT: [[WIDENABLE_COND9:%.*]] = call i1 @llvm.experimental.widenable.condition() 1377; CHECK-NEXT: [[TMP11:%.*]] = and i1 [[TMP8]], [[WIDENABLE_COND9]] 1378; CHECK-NEXT: br i1 [[TMP11]], label [[GUARDED6]], label [[DEOPT7:%.*]], !prof !0 1379; CHECK: deopt7: 1380; CHECK-NEXT: [[DEOPTCALL8:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1381; CHECK-NEXT: ret i32 [[DEOPTCALL8]] 1382; CHECK: guarded6: 1383; CHECK-NEXT: [[ARRAY_3_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY_3:%.*]], i64 [[I_I64]] 1384; CHECK-NEXT: [[ARRAY_3_I:%.*]] = load i32, i32* [[ARRAY_3_I_PTR]], align 4 1385; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC_2]], [[ARRAY_3_I]] 1386; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1 1387; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]] 1388; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 1389; CHECK: exit.loopexit: 1390; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED6]] ] 1391; CHECK-NEXT: br label [[EXIT]] 1392; CHECK: exit: 1393; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 1394; CHECK-NEXT: ret i32 [[RESULT]] 1395; 1396entry: 1397 %tmp5 = icmp eq i32 %n, 0 1398 br i1 %tmp5, label %exit, label %loop.preheader 1399 1400loop.preheader: ; preds = %entry 1401 br label %loop 1402 1403loop: ; preds = %guarded6, %loop.preheader 1404 %loop.acc = phi i32 [ %loop.acc.next, %guarded6 ], [ 0, %loop.preheader ] 1405 %i = phi i32 [ %i.next, %guarded6 ], [ 0, %loop.preheader ] 1406 %within.bounds.1 = icmp ult i32 %i, %length.1 1407 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 1408 %exiplicit_guard_cond = and i1 %within.bounds.1, %widenable_cond 1409 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 1410 1411deopt: ; preds = %loop 1412 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1413 ret i32 %deoptcall 1414 1415guarded: ; preds = %loop 1416 %i.i64 = zext i32 %i to i64 1417 %array.1.i.ptr = getelementptr inbounds i32, i32* %array.1, i64 %i.i64 1418 %array.1.i = load i32, i32* %array.1.i.ptr, align 4 1419 %loop.acc.1 = add i32 %loop.acc, %array.1.i 1420 %within.bounds.2 = icmp ult i32 %i, %length.2 1421 %widenable_cond4 = call i1 @llvm.experimental.widenable.condition() 1422 %exiplicit_guard_cond5 = and i1 %within.bounds.2, %widenable_cond4 1423 br i1 %exiplicit_guard_cond5, label %guarded1, label %deopt2, !prof !0 1424 1425deopt2: ; preds = %guarded 1426 %deoptcall3 = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1427 ret i32 %deoptcall3 1428 1429guarded1: ; preds = %guarded 1430 %array.2.i.ptr = getelementptr inbounds i32, i32* %array.2, i64 %i.i64 1431 %array.2.i = load i32, i32* %array.2.i.ptr, align 4 1432 %loop.acc.2 = add i32 %loop.acc.1, %array.2.i 1433 %within.bounds.3 = icmp ult i32 %i, %length.3 1434 %widenable_cond9 = call i1 @llvm.experimental.widenable.condition() 1435 %exiplicit_guard_cond10 = and i1 %within.bounds.3, %widenable_cond9 1436 br i1 %exiplicit_guard_cond10, label %guarded6, label %deopt7, !prof !0 1437 1438deopt7: ; preds = %guarded1 1439 %deoptcall8 = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1440 ret i32 %deoptcall8 1441 1442guarded6: ; preds = %guarded1 1443 %array.3.i.ptr = getelementptr inbounds i32, i32* %array.3, i64 %i.i64 1444 %array.3.i = load i32, i32* %array.3.i.ptr, align 4 1445 %loop.acc.next = add i32 %loop.acc.2, %array.3.i 1446 %i.next = add nuw i32 %i, 1 1447 %continue = icmp ult i32 %i.next, %n 1448 br i1 %continue, label %loop, label %exit, !prof !2 1449 1450exit: ; preds = %guarded6, %entry 1451 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded6 ] 1452 ret i32 %result 1453} 1454 1455define i32 @unsigned_loop_0_to_n_unrelated_condition(i32* %array, i32 %length, i32 %n, i32 %x) { 1456; CHECK-LABEL: @unsigned_loop_0_to_n_unrelated_condition( 1457; CHECK-NEXT: entry: 1458; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0 1459; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 1460; CHECK: loop.preheader: 1461; CHECK-NEXT: [[TMP0:%.*]] = icmp ule i32 [[N]], [[LENGTH:%.*]] 1462; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]] 1463; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]] 1464; CHECK-NEXT: br label [[LOOP:%.*]] 1465; CHECK: loop: 1466; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 1467; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 1468; CHECK-NEXT: [[UNRELATED_COND:%.*]] = icmp ult i32 [[X:%.*]], [[LENGTH]] 1469; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 1470; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[UNRELATED_COND]], [[TMP2]] 1471; CHECK-NEXT: [[TMP4:%.*]] = and i1 [[TMP3]], [[WIDENABLE_COND]] 1472; CHECK-NEXT: br i1 [[TMP4]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 1473; CHECK: deopt: 1474; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1475; CHECK-NEXT: ret i32 [[DEOPTCALL]] 1476; CHECK: guarded: 1477; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 1478; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 1479; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 1480; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 1481; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1 1482; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]] 1483; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 1484; CHECK: exit.loopexit: 1485; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 1486; CHECK-NEXT: br label [[EXIT]] 1487; CHECK: exit: 1488; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 1489; CHECK-NEXT: ret i32 [[RESULT]] 1490; 1491entry: 1492 %tmp5 = icmp eq i32 %n, 0 1493 br i1 %tmp5, label %exit, label %loop.preheader 1494 1495loop.preheader: ; preds = %entry 1496 br label %loop 1497 1498loop: ; preds = %guarded, %loop.preheader 1499 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 1500 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 1501 %within.bounds = icmp ult i32 %i, %length 1502 %unrelated.cond = icmp ult i32 %x, %length 1503 %guard.cond = and i1 %within.bounds, %unrelated.cond 1504 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 1505 %exiplicit_guard_cond = and i1 %guard.cond, %widenable_cond 1506 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 1507 1508deopt: ; preds = %loop 1509 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1510 ret i32 %deoptcall 1511 1512guarded: ; preds = %loop 1513 %i.i64 = zext i32 %i to i64 1514 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 1515 %array.i = load i32, i32* %array.i.ptr, align 4 1516 %loop.acc.next = add i32 %loop.acc, %array.i 1517 %i.next = add nuw i32 %i, 1 1518 %continue = icmp ult i32 %i.next, %n 1519 br i1 %continue, label %loop, label %exit, !prof !2 1520 1521exit: ; preds = %guarded, %entry 1522 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 1523 ret i32 %result 1524} 1525 1526define i32 @test_no_widened_conditions(i32* %array, i32 %length, i32 %n, i32 %x1, i32 %x2, i32 %x3) { 1527; CHECK-LABEL: @test_no_widened_conditions( 1528; CHECK-NEXT: entry: 1529; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0 1530; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 1531; CHECK: loop.preheader: 1532; CHECK-NEXT: br label [[LOOP:%.*]] 1533; CHECK: loop: 1534; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 1535; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 1536; CHECK-NEXT: [[UNRELATED_COND_1:%.*]] = icmp eq i32 [[X1:%.*]], [[I]] 1537; CHECK-NEXT: [[UNRELATED_COND_2:%.*]] = icmp eq i32 [[X2:%.*]], [[I]] 1538; CHECK-NEXT: [[UNRELATED_COND_3:%.*]] = icmp eq i32 [[X3:%.*]], [[I]] 1539; CHECK-NEXT: [[UNRELATED_COND_AND_1:%.*]] = and i1 [[UNRELATED_COND_1]], [[UNRELATED_COND_2]] 1540; CHECK-NEXT: [[GUARD_COND:%.*]] = and i1 [[UNRELATED_COND_AND_1]], [[UNRELATED_COND_3]] 1541; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 1542; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[GUARD_COND]], [[WIDENABLE_COND]] 1543; CHECK-NEXT: br i1 [[EXIPLICIT_GUARD_COND]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 1544; CHECK: deopt: 1545; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1546; CHECK-NEXT: ret i32 [[DEOPTCALL]] 1547; CHECK: guarded: 1548; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 1549; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 1550; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 1551; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 1552; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1 1553; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]] 1554; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 1555; CHECK: exit.loopexit: 1556; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 1557; CHECK-NEXT: br label [[EXIT]] 1558; CHECK: exit: 1559; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 1560; CHECK-NEXT: ret i32 [[RESULT]] 1561; 1562entry: 1563 %tmp5 = icmp eq i32 %n, 0 1564 br i1 %tmp5, label %exit, label %loop.preheader 1565 1566loop.preheader: ; preds = %entry 1567 br label %loop 1568 1569loop: ; preds = %guarded, %loop.preheader 1570 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 1571 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 1572 %unrelated.cond.1 = icmp eq i32 %x1, %i 1573 %unrelated.cond.2 = icmp eq i32 %x2, %i 1574 %unrelated.cond.3 = icmp eq i32 %x3, %i 1575 %unrelated.cond.and.1 = and i1 %unrelated.cond.1, %unrelated.cond.2 1576 %guard.cond = and i1 %unrelated.cond.and.1, %unrelated.cond.3 1577 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 1578 %exiplicit_guard_cond = and i1 %guard.cond, %widenable_cond 1579 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 1580 1581deopt: ; preds = %loop 1582 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1583 ret i32 %deoptcall 1584 1585guarded: ; preds = %loop 1586 %i.i64 = zext i32 %i to i64 1587 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 1588 %array.i = load i32, i32* %array.i.ptr, align 4 1589 %loop.acc.next = add i32 %loop.acc, %array.i 1590 %i.next = add nuw i32 %i, 1 1591 %continue = icmp ult i32 %i.next, %n 1592 br i1 %continue, label %loop, label %exit, !prof !2 1593 1594exit: ; preds = %guarded, %entry 1595 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 1596 ret i32 %result 1597} 1598 1599define i32 @signed_loop_start_to_n_loop_variant_bound(i32* %array, i32 %x, i32 %start, i32 %n) { 1600; CHECK-LABEL: @signed_loop_start_to_n_loop_variant_bound( 1601; CHECK-NEXT: entry: 1602; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0 1603; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 1604; CHECK: loop.preheader: 1605; CHECK-NEXT: br label [[LOOP:%.*]] 1606; CHECK: loop: 1607; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 1608; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ [[START:%.*]], [[LOOP_PREHEADER]] ] 1609; CHECK-NEXT: [[BOUND:%.*]] = add i32 [[I]], [[X:%.*]] 1610; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i32 [[I]], [[BOUND]] 1611; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 1612; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[WITHIN_BOUNDS]], [[WIDENABLE_COND]] 1613; CHECK-NEXT: br i1 [[EXIPLICIT_GUARD_COND]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 1614; CHECK: deopt: 1615; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1616; CHECK-NEXT: ret i32 [[DEOPTCALL]] 1617; CHECK: guarded: 1618; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 1619; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 1620; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 1621; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 1622; CHECK-NEXT: [[I_NEXT]] = add nsw i32 [[I]], 1 1623; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]] 1624; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 1625; CHECK: exit.loopexit: 1626; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 1627; CHECK-NEXT: br label [[EXIT]] 1628; CHECK: exit: 1629; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 1630; CHECK-NEXT: ret i32 [[RESULT]] 1631; 1632entry: 1633 %tmp5 = icmp sle i32 %n, 0 1634 br i1 %tmp5, label %exit, label %loop.preheader 1635 1636loop.preheader: ; preds = %entry 1637 br label %loop 1638 1639loop: ; preds = %guarded, %loop.preheader 1640 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 1641 %i = phi i32 [ %i.next, %guarded ], [ %start, %loop.preheader ] 1642 %bound = add i32 %i, %x 1643 %within.bounds = icmp ult i32 %i, %bound 1644 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 1645 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 1646 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 1647 1648deopt: ; preds = %loop 1649 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1650 ret i32 %deoptcall 1651 1652guarded: ; preds = %loop 1653 %i.i64 = zext i32 %i to i64 1654 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 1655 %array.i = load i32, i32* %array.i.ptr, align 4 1656 %loop.acc.next = add i32 %loop.acc, %array.i 1657 %i.next = add nsw i32 %i, 1 1658 %continue = icmp slt i32 %i.next, %n 1659 br i1 %continue, label %loop, label %exit, !prof !2 1660 1661exit: ; preds = %guarded, %entry 1662 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 1663 ret i32 %result 1664} 1665 1666define i32 @signed_loop_start_to_n_non_monotonic_predicate(i32* %array, i32 %x, i32 %start, i32 %n) { 1667; CHECK-LABEL: @signed_loop_start_to_n_non_monotonic_predicate( 1668; CHECK-NEXT: entry: 1669; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0 1670; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 1671; CHECK: loop.preheader: 1672; CHECK-NEXT: br label [[LOOP:%.*]] 1673; CHECK: loop: 1674; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 1675; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ [[START:%.*]], [[LOOP_PREHEADER]] ] 1676; CHECK-NEXT: [[GUARD_COND:%.*]] = icmp eq i32 [[I]], [[X:%.*]] 1677; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 1678; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[GUARD_COND]], [[WIDENABLE_COND]] 1679; CHECK-NEXT: br i1 [[EXIPLICIT_GUARD_COND]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 1680; CHECK: deopt: 1681; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1682; CHECK-NEXT: ret i32 [[DEOPTCALL]] 1683; CHECK: guarded: 1684; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 1685; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 1686; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 1687; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 1688; CHECK-NEXT: [[I_NEXT]] = add nsw i32 [[I]], 1 1689; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]] 1690; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 1691; CHECK: exit.loopexit: 1692; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 1693; CHECK-NEXT: br label [[EXIT]] 1694; CHECK: exit: 1695; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 1696; CHECK-NEXT: ret i32 [[RESULT]] 1697; 1698entry: 1699 %tmp5 = icmp sle i32 %n, 0 1700 br i1 %tmp5, label %exit, label %loop.preheader 1701 1702loop.preheader: ; preds = %entry 1703 br label %loop 1704 1705loop: ; preds = %guarded, %loop.preheader 1706 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 1707 %i = phi i32 [ %i.next, %guarded ], [ %start, %loop.preheader ] 1708 %guard.cond = icmp eq i32 %i, %x 1709 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 1710 %exiplicit_guard_cond = and i1 %guard.cond, %widenable_cond 1711 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 1712 1713deopt: ; preds = %loop 1714 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1715 ret i32 %deoptcall 1716 1717guarded: ; preds = %loop 1718 %i.i64 = zext i32 %i to i64 1719 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 1720 %array.i = load i32, i32* %array.i.ptr, align 4 1721 %loop.acc.next = add i32 %loop.acc, %array.i 1722 %i.next = add nsw i32 %i, 1 1723 %continue = icmp slt i32 %i.next, %n 1724 br i1 %continue, label %loop, label %exit, !prof !2 1725 1726exit: ; preds = %guarded, %entry 1727 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 1728 ret i32 %result 1729} 1730 1731define i32 @unsigned_loop_0_to_n_hoist_length(i32* %array, i16 %length.i16, i32 %n) { 1732; CHECK-LABEL: @unsigned_loop_0_to_n_hoist_length( 1733; CHECK-NEXT: entry: 1734; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0 1735; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 1736; CHECK: loop.preheader: 1737; CHECK-NEXT: [[TMP0:%.*]] = zext i16 [[LENGTH_I16:%.*]] to i32 1738; CHECK-NEXT: [[TMP1:%.*]] = icmp ule i32 [[N]], [[TMP0]] 1739; CHECK-NEXT: [[TMP2:%.*]] = icmp ult i32 0, [[TMP0]] 1740; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[TMP1]] 1741; CHECK-NEXT: br label [[LOOP:%.*]] 1742; CHECK: loop: 1743; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 1744; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 1745; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 1746; CHECK-NEXT: [[TMP4:%.*]] = and i1 [[TMP3]], [[WIDENABLE_COND]] 1747; CHECK-NEXT: br i1 [[TMP4]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 1748; CHECK: deopt: 1749; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1750; CHECK-NEXT: ret i32 [[DEOPTCALL]] 1751; CHECK: guarded: 1752; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 1753; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 1754; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 1755; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 1756; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1 1757; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]] 1758; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 1759; CHECK: exit.loopexit: 1760; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 1761; CHECK-NEXT: br label [[EXIT]] 1762; CHECK: exit: 1763; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 1764; CHECK-NEXT: ret i32 [[RESULT]] 1765; 1766entry: 1767 %tmp5 = icmp eq i32 %n, 0 1768 br i1 %tmp5, label %exit, label %loop.preheader 1769 1770loop.preheader: ; preds = %entry 1771 br label %loop 1772 1773loop: ; preds = %guarded, %loop.preheader 1774 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 1775 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 1776 %length = zext i16 %length.i16 to i32 1777 %within.bounds = icmp ult i32 %i, %length 1778 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 1779 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 1780 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 1781 1782deopt: ; preds = %loop 1783 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1784 ret i32 %deoptcall 1785 1786guarded: ; preds = %loop 1787 %i.i64 = zext i32 %i to i64 1788 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 1789 %array.i = load i32, i32* %array.i.ptr, align 4 1790 %loop.acc.next = add i32 %loop.acc, %array.i 1791 %i.next = add nuw i32 %i, 1 1792 %continue = icmp ult i32 %i.next, %n 1793 br i1 %continue, label %loop, label %exit, !prof !2 1794 1795exit: ; preds = %guarded, %entry 1796 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 1797 ret i32 %result 1798} 1799 1800define i32 @unsigned_loop_0_to_n_cant_hoist_length(i32* %array, i32 %length, i32 %divider, i32 %n) { 1801; CHECK-LABEL: @unsigned_loop_0_to_n_cant_hoist_length( 1802; CHECK-NEXT: entry: 1803; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0 1804; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 1805; CHECK: loop.preheader: 1806; CHECK-NEXT: br label [[LOOP:%.*]] 1807; CHECK: loop: 1808; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 1809; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 1810; CHECK-NEXT: [[LENGTH_UDIV:%.*]] = udiv i32 [[LENGTH:%.*]], [[DIVIDER:%.*]] 1811; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 1812; CHECK-NEXT: [[TMP0:%.*]] = icmp ule i32 [[N]], [[LENGTH_UDIV]] 1813; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH_UDIV]] 1814; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]] 1815; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]] 1816; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 1817; CHECK: deopt: 1818; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1819; CHECK-NEXT: ret i32 [[DEOPTCALL]] 1820; CHECK: guarded: 1821; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 1822; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 1823; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 1824; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 1825; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1 1826; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]] 1827; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 1828; CHECK: exit.loopexit: 1829; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 1830; CHECK-NEXT: br label [[EXIT]] 1831; CHECK: exit: 1832; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 1833; CHECK-NEXT: ret i32 [[RESULT]] 1834; 1835entry: 1836 %tmp5 = icmp eq i32 %n, 0 1837 br i1 %tmp5, label %exit, label %loop.preheader 1838 1839loop.preheader: ; preds = %entry 1840 br label %loop 1841 1842loop: ; preds = %guarded, %loop.preheader 1843 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 1844 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 1845 %length.udiv = udiv i32 %length, %divider 1846 %within.bounds = icmp ult i32 %i, %length.udiv 1847 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 1848 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond 1849 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 1850 1851deopt: ; preds = %loop 1852 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1853 ret i32 %deoptcall 1854 1855guarded: ; preds = %loop 1856 %i.i64 = zext i32 %i to i64 1857 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 1858 %array.i = load i32, i32* %array.i.ptr, align 4 1859 %loop.acc.next = add i32 %loop.acc, %array.i 1860 %i.next = add nuw i32 %i, 1 1861 %continue = icmp ult i32 %i.next, %n 1862 br i1 %continue, label %loop, label %exit, !prof !2 1863 1864exit: ; preds = %guarded, %entry 1865 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 1866 ret i32 %result 1867} 1868 1869; Make sure that if we're going to consider a branch widenable, that the 1870; call to widenable condition is actually present. 1871define i32 @negative_WC_required(i32* %array, i32 %length, i32 %n, i1 %unrelated) { 1872; CHECK-LABEL: @negative_WC_required( 1873; CHECK-NEXT: entry: 1874; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0 1875; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 1876; CHECK: loop.preheader: 1877; CHECK-NEXT: br label [[LOOP:%.*]] 1878; CHECK: loop: 1879; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 1880; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i32 [[I]], [[LENGTH:%.*]] 1881; CHECK-NEXT: [[NOT_WIDENABLE:%.*]] = and i1 [[WITHIN_BOUNDS]], [[UNRELATED:%.*]] 1882; CHECK-NEXT: br i1 [[NOT_WIDENABLE]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 1883; CHECK: deopt: 1884; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1885; CHECK-NEXT: ret i32 [[DEOPTCALL]] 1886; CHECK: guarded: 1887; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 1888; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 1889; CHECK-NEXT: store i32 0, i32* [[ARRAY_I_PTR]], align 4 1890; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1 1891; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]] 1892; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 1893; CHECK: exit.loopexit: 1894; CHECK-NEXT: br label [[EXIT]] 1895; CHECK: exit: 1896; CHECK-NEXT: ret i32 0 1897; 1898entry: 1899 %tmp5 = icmp eq i32 %n, 0 1900 br i1 %tmp5, label %exit, label %loop.preheader 1901 1902loop.preheader: ; preds = %entry 1903 br label %loop 1904 1905loop: 1906 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 1907 %within.bounds = icmp ult i32 %i, %length 1908 %not_widenable = and i1 %within.bounds, %unrelated 1909 br i1 %not_widenable, label %guarded, label %deopt, !prof !0 1910 1911deopt: 1912 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1913 ret i32 %deoptcall 1914 1915guarded: ; preds = %loop 1916 %i.i64 = zext i32 %i to i64 1917 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 1918 store i32 0, i32* %array.i.ptr, align 4 1919 %i.next = add nuw i32 %i, 1 1920 %continue = icmp ult i32 %i.next, %n 1921 br i1 %continue, label %loop, label %exit, !prof !2 1922 1923exit: ; preds = %guarded, %entry 1924 ret i32 0 1925} 1926 1927define i32 @swapped_wb(i32* %array, i32 %length, i32 %n) { 1928; CHECK-LABEL: @swapped_wb( 1929; CHECK-NEXT: entry: 1930; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0 1931; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]] 1932; CHECK: loop.preheader: 1933; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition() 1934; CHECK-NEXT: [[TMP0:%.*]] = icmp ule i32 [[N]], [[LENGTH:%.*]] 1935; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]] 1936; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]] 1937; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]] 1938; CHECK-NEXT: br label [[LOOP:%.*]] 1939; CHECK: loop: 1940; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ] 1941; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ] 1942; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0 1943; CHECK: deopt: 1944; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1945; CHECK-NEXT: ret i32 [[DEOPTCALL]] 1946; CHECK: guarded: 1947; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64 1948; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]] 1949; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4 1950; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]] 1951; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1 1952; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]] 1953; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1 1954; CHECK: exit.loopexit: 1955; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ] 1956; CHECK-NEXT: br label [[EXIT]] 1957; CHECK: exit: 1958; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ] 1959; CHECK-NEXT: ret i32 [[RESULT]] 1960; 1961entry: 1962 %tmp5 = icmp eq i32 %n, 0 1963 br i1 %tmp5, label %exit, label %loop.preheader 1964 1965loop.preheader: ; preds = %entry 1966 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 1967 br label %loop 1968 1969loop: ; preds = %guarded, %loop.preheader 1970 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ] 1971 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ] 1972 %within.bounds = icmp ult i32 %i, %length 1973 %exiplicit_guard_cond = and i1 %widenable_cond, %within.bounds 1974 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0 1975 1976deopt: ; preds = %loop 1977 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ] 1978 ret i32 %deoptcall 1979 1980guarded: ; preds = %loop 1981 %i.i64 = zext i32 %i to i64 1982 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64 1983 %array.i = load i32, i32* %array.i.ptr, align 4 1984 %loop.acc.next = add i32 %loop.acc, %array.i 1985 %i.next = add nuw i32 %i, 1 1986 %continue = icmp ult i32 %i.next, %n 1987 br i1 %continue, label %loop, label %exit, !prof !2 1988 1989exit: ; preds = %guarded, %entry 1990 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ] 1991 ret i32 %result 1992} 1993 1994declare i32 @llvm.experimental.deoptimize.i32(...) 1995 1996; Function Attrs: inaccessiblememonly nounwind 1997declare i1 @llvm.experimental.widenable.condition() #0 1998 1999attributes #0 = { inaccessiblememonly nounwind } 2000 2001!0 = !{!"branch_weights", i32 1048576, i32 1} 2002!1 = !{i32 1, i32 -2147483648} 2003!2 = !{!"branch_weights", i32 1024, i32 1} 2004