1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s 3; PR1786 4 5define i32 @main() { 6; CHECK-LABEL: @main( 7; CHECK-NEXT: entry: 8; CHECK-NEXT: [[RETVAL:%.*]] = alloca i32, align 4 9; CHECK-NEXT: [[I:%.*]] = alloca i32, align 4 10; CHECK-NEXT: [[Z:%.*]] = alloca i32, align 4 11; CHECK-NEXT: [[Z16:%.*]] = alloca i32, align 4 12; CHECK-NEXT: %"alloca point" = bitcast i32 0 to i32 13; CHECK-NEXT: store i32 0, ptr [[I]], align 4 14; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i8 1, 0 15; CHECK-NEXT: br i1 [[TOBOOL]], label [[COND_TRUE:%.*]], label [[COND_FALSE33:%.*]] 16; CHECK: cond_true: 17; CHECK-NEXT: store i32 0, ptr [[Z]], align 4 18; CHECK-NEXT: br label [[BB:%.*]] 19; CHECK: bb: 20; CHECK-NEXT: [[TMP:%.*]] = load i32, ptr [[Z]], align 4 21; CHECK-NEXT: [[TMP1:%.*]] = sub i32 [[TMP]], 16384 22; CHECK-NEXT: store i32 [[TMP1]], ptr [[Z]], align 4 23; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[I]], align 4 24; CHECK-NEXT: [[TMP3:%.*]] = add i32 [[TMP2]], 1 25; CHECK-NEXT: store i32 [[TMP3]], ptr [[I]], align 4 26; CHECK-NEXT: [[TMP4:%.*]] = load i32, ptr [[I]], align 4 27; CHECK-NEXT: [[TMP5:%.*]] = icmp sgt i32 [[TMP4]], 262144 28; CHECK-NEXT: [[TMP56:%.*]] = zext i1 [[TMP5]] to i8 29; CHECK-NEXT: [[TOBOOL7:%.*]] = icmp ne i8 [[TMP56]], 0 30; CHECK-NEXT: br i1 [[TOBOOL7]], label [[COND_TRUE8:%.*]], label [[COND_NEXT:%.*]] 31; CHECK: cond_true8: 32; CHECK-NEXT: call void @abort() 33; CHECK-NEXT: unreachable 34; CHECK: cond_next: 35; CHECK-NEXT: [[TMP9:%.*]] = load i32, ptr [[Z]], align 4 36; CHECK-NEXT: [[TMP10:%.*]] = icmp ne i32 [[TMP9]], 0 37; CHECK-NEXT: [[TMP1011:%.*]] = zext i1 [[TMP10]] to i8 38; CHECK-NEXT: [[TOBOOL12:%.*]] = icmp ne i8 [[TMP1011]], 0 39; CHECK-NEXT: br i1 [[TOBOOL12]], label [[BB]], label [[BB13:%.*]] 40; CHECK: bb13: 41; CHECK-NEXT: call void @exit(i32 0) 42; CHECK-NEXT: unreachable 43; CHECK: cond_false33: 44; CHECK-NEXT: call void @exit(i32 0) 45; CHECK-NEXT: unreachable 46; 47entry: 48 %retval = alloca i32, align 4 ; <ptr> [#uses=1] 49 %i = alloca i32, align 4 ; <ptr> [#uses=7] 50 %z = alloca i32, align 4 ; <ptr> [#uses=4] 51 %z16 = alloca i32, align 4 ; <ptr> [#uses=4] 52 %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] 53 store i32 0, ptr %i 54 %toBool = icmp ne i8 1, 0 ; <i1> [#uses=1] 55 br i1 %toBool, label %cond_true, label %cond_false 56 57cond_true: ; preds = %entry 58 store i32 0, ptr %z 59 br label %bb 60 61bb: ; preds = %cond_next, %cond_true 62 %tmp = load i32, ptr %z ; <i32> [#uses=1] 63 %tmp1 = sub i32 %tmp, 16384 ; <i32> [#uses=1] 64 store i32 %tmp1, ptr %z 65 %tmp2 = load i32, ptr %i ; <i32> [#uses=1] 66 %tmp3 = add i32 %tmp2, 1 ; <i32> [#uses=1] 67 store i32 %tmp3, ptr %i 68 %tmp4 = load i32, ptr %i ; <i32> [#uses=1] 69 %tmp5 = icmp sgt i32 %tmp4, 262144 ; <i1> [#uses=1] 70 %tmp56 = zext i1 %tmp5 to i8 ; <i8> [#uses=1] 71 %toBool7 = icmp ne i8 %tmp56, 0 ; <i1> [#uses=1] 72 br i1 %toBool7, label %cond_true8, label %cond_next 73 74cond_true8: ; preds = %bb 75 call void @abort( ) 76 unreachable 77 78cond_next: ; preds = %bb 79 %tmp9 = load i32, ptr %z ; <i32> [#uses=1] 80 %tmp10 = icmp ne i32 %tmp9, 0 ; <i1> [#uses=1] 81 %tmp1011 = zext i1 %tmp10 to i8 ; <i8> [#uses=1] 82 %toBool12 = icmp ne i8 %tmp1011, 0 ; <i1> [#uses=1] 83 br i1 %toBool12, label %bb, label %bb13 84 85bb13: ; preds = %cond_next 86 call void @exit( i32 0 ) 87 unreachable 88 89cond_false: ; preds = %entry 90 %toBool14 = icmp ne i8 1, 0 ; <i1> [#uses=1] 91 br i1 %toBool14, label %cond_true15, label %cond_false33 92 93cond_true15: ; preds = %cond_false 94 store i32 0, ptr %z16 95 br label %bb17 96 97bb17: ; preds = %cond_next27, %cond_true15 98 %tmp18 = load i32, ptr %z16 ; <i32> [#uses=1] 99 %tmp19 = sub i32 %tmp18, 16384 ; <i32> [#uses=1] 100 store i32 %tmp19, ptr %z16 101 %tmp20 = load i32, ptr %i ; <i32> [#uses=1] 102 %tmp21 = add i32 %tmp20, 1 ; <i32> [#uses=1] 103 store i32 %tmp21, ptr %i 104 %tmp22 = load i32, ptr %i ; <i32> [#uses=1] 105 %tmp23 = icmp sgt i32 %tmp22, 262144 ; <i1> [#uses=1] 106 %tmp2324 = zext i1 %tmp23 to i8 ; <i8> [#uses=1] 107 %toBool25 = icmp ne i8 %tmp2324, 0 ; <i1> [#uses=1] 108 br i1 %toBool25, label %cond_true26, label %cond_next27 109 110cond_true26: ; preds = %bb17 111 call void @abort( ) 112 unreachable 113 114cond_next27: ; preds = %bb17 115 %tmp28 = load i32, ptr %z16 ; <i32> [#uses=1] 116 %tmp29 = icmp ne i32 %tmp28, 0 ; <i1> [#uses=1] 117 %tmp2930 = zext i1 %tmp29 to i8 ; <i8> [#uses=1] 118 %toBool31 = icmp ne i8 %tmp2930, 0 ; <i1> [#uses=1] 119 br i1 %toBool31, label %bb17, label %bb32 120 121bb32: ; preds = %cond_next27 122 call void @exit( i32 0 ) 123 unreachable 124 125cond_false33: ; preds = %cond_false 126 call void @exit( i32 0 ) 127 unreachable 128 129cond_next34: ; No predecessors! 130 br label %cond_next35 131 132cond_next35: ; preds = %cond_next34 133 br label %return 134 135return: ; preds = %cond_next35 136 %retval36 = load i32, ptr %retval ; <i32> [#uses=1] 137 ret i32 %retval36 138} 139 140declare void @abort() 141 142declare void @exit(i32) 143