1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -S -O2 -scev-cheap-expansion-budget=1024 %s | FileCheck %s 3 4; See https://bugs.llvm.org/show_bug.cgi?id=45360 5; This is reduced from that (runnable) test. 6; The remainder operation is originally guarded, it never divides by zero. 7; Indvars should not make it execute unconditionally. 8 9target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 10target triple = "x86_64-pc-linux-gnu" 11 12@f = dso_local global i32 0, align 4 13@a = dso_local global i32 0, align 4 14@d = dso_local global i32 0, align 4 15@c = dso_local global i32 0, align 4 16@b = dso_local global i32 0, align 4 17@e = dso_local global i32 0, align 4 18 19define dso_local i32 @main() { 20; CHECK-LABEL: @main( 21; CHECK-NEXT: bb: 22; CHECK-NEXT: [[I6:%.*]] = load i32, i32* @a, align 4 23; CHECK-NEXT: [[I24:%.*]] = load i32, i32* @b, align 4 24; CHECK-NEXT: [[D_PROMOTED8:%.*]] = load i32, i32* @d, align 4 25; CHECK-NEXT: br label [[BB19:%.*]] 26; CHECK: bb19: 27; CHECK-NEXT: [[I8_LCSSA9:%.*]] = phi i32 [ [[D_PROMOTED8]], [[BB:%.*]] ], [ [[I8:%.*]], [[BB27:%.*]] ] 28; CHECK-NEXT: [[I8]] = and i32 [[I8_LCSSA9]], [[I6]] 29; CHECK-NEXT: [[I21:%.*]] = icmp eq i32 [[I8]], 0 30; CHECK-NEXT: br i1 [[I21]], label [[BB27_THREAD:%.*]], label [[BB27]] 31; CHECK: bb27.thread: 32; CHECK-NEXT: store i32 -1, i32* @f, align 4 33; CHECK-NEXT: store i32 0, i32* @d, align 4 34; CHECK-NEXT: store i32 0, i32* @c, align 4 35; CHECK-NEXT: br label [[BB32:%.*]] 36; CHECK: bb27: 37; CHECK-NEXT: [[I26:%.*]] = urem i32 [[I24]], [[I8]] 38; CHECK-NEXT: store i32 [[I26]], i32* @e, align 4 39; CHECK-NEXT: [[I30:%.*]] = icmp eq i32 [[I26]], 0 40; CHECK-NEXT: br i1 [[I30]], label [[BB32_LOOPEXIT:%.*]], label [[BB19]] 41; CHECK: bb32.loopexit: 42; CHECK-NEXT: store i32 -1, i32* @f, align 4 43; CHECK-NEXT: store i32 [[I8]], i32* @d, align 4 44; CHECK-NEXT: br label [[BB32]] 45; CHECK: bb32: 46; CHECK-NEXT: [[C_SINK:%.*]] = phi i32* [ @c, [[BB32_LOOPEXIT]] ], [ @e, [[BB27_THREAD]] ] 47; CHECK-NEXT: store i32 0, i32* [[C_SINK]], align 4 48; CHECK-NEXT: ret i32 0 49; 50bb: 51 %i = alloca i32, align 4 52 store i32 0, i32* %i, align 4 53 br label %bb1 54 55bb1: 56 store i32 0, i32* @f, align 4 57 br label %bb2 58 59bb2: 60 %i3 = load i32, i32* @f, align 4 61 %i4 = icmp sge i32 %i3, 0 62 br i1 %i4, label %bb5, label %bb12 63 64bb5: 65 %i6 = load i32, i32* @a, align 4 66 %i7 = load i32, i32* @d, align 4 67 %i8 = and i32 %i7, %i6 68 store i32 %i8, i32* @d, align 4 69 br label %bb9 70 71bb9: 72 %i10 = load i32, i32* @f, align 4 73 %i11 = add nsw i32 %i10, -1 74 store i32 %i11, i32* @f, align 4 75 br label %bb2 76 77bb12: 78 store i32 0, i32* @c, align 4 79 br label %bb13 80 81bb13: 82 %i14 = load i32, i32* @c, align 4 83 %i15 = icmp sle i32 %i14, 0 84 br i1 %i15, label %bb16, label %bb39 85 86bb16: 87 %i17 = load i32, i32* @f, align 4 88 %i18 = icmp ne i32 %i17, 0 89 br i1 %i18, label %bb19, label %bb34 90 91bb19: 92 %i20 = load i32, i32* @d, align 4 93 %i21 = icmp eq i32 %i20, 0 94 br i1 %i21, label %bb22, label %bb23 95 96bb22: 97 br label %bb27 98 99bb23: 100 %i24 = load i32, i32* @b, align 4 101 %i25 = load i32, i32* @d, align 4 102 %i26 = urem i32 %i24, %i25 103 br label %bb27 104 105bb27: 106 %i28 = phi i32 [ 0, %bb22 ], [ %i26, %bb23 ] 107 store i32 %i28, i32* @e, align 4 108 %i29 = load i32, i32* @e, align 4 109 %i30 = icmp ne i32 %i29, 0 110 br i1 %i30, label %bb31, label %bb32 111 112bb31: 113 br label %bb33 114 115bb32: 116 ret i32 0 117 118bb33: 119 br label %bb35 120 121bb34: 122 store i32 0, i32* @d, align 4 123 br label %bb35 124 125bb35: 126 br label %bb36 127 128bb36: 129 %i37 = load i32, i32* @c, align 4 130 %i38 = add nsw i32 %i37, 1 131 store i32 %i38, i32* @c, align 4 132 br label %bb13 133 134bb39: 135 br label %bb1 136} 137