1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -simplifycfg -S < %s | FileCheck %s 3 4%struct.Counters = type { i64, i64, i64, [8 x i8] } 5 6@m = global i64 3, align 8 7@counters = global %struct.Counters zeroinitializer, align 16 8 9define i32 @align_both_equal() local_unnamed_addr { 10; CHECK-LABEL: @align_both_equal( 11; CHECK-NEXT: entry: 12; CHECK-NEXT: [[TMP0:%.*]] = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 13; CHECK-NEXT: [[TMP1:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 1, i64 1> 14; CHECK-NEXT: store <2 x i64> [[TMP1]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 15; CHECK-NEXT: [[TMP2:%.*]] = load i64, i64* @m, align 8 16; CHECK-NEXT: [[AND:%.*]] = and i64 [[TMP2]], 1 17; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i64 [[AND]], 0 18; CHECK-NEXT: [[TMP3:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 2, i64 2> 19; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TOBOOL]], <2 x i64> [[TMP1]], <2 x i64> [[TMP3]] 20; CHECK-NEXT: [[AND4:%.*]] = and i64 [[TMP2]], 2 21; CHECK-NEXT: [[TOBOOL5:%.*]] = icmp eq i64 [[AND4]], 0 22; CHECK-NEXT: [[TMP5:%.*]] = add nsw <2 x i64> [[TMP4]], <i64 1, i64 1> 23; CHECK-NEXT: [[DOT:%.*]] = select i1 [[TOBOOL5]], <2 x i64> [[TMP4]], <2 x i64> [[TMP5]] 24; CHECK-NEXT: [[TMP6:%.*]] = xor i1 [[TOBOOL]], true 25; CHECK-NEXT: [[TMP7:%.*]] = xor i1 [[TOBOOL5]], true 26; CHECK-NEXT: [[TMP8:%.*]] = or i1 [[TMP6]], [[TMP7]] 27; CHECK-NEXT: br i1 [[TMP8]], label [[TMP9:%.*]], label [[TMP10:%.*]] 28; CHECK: store <2 x i64> [[DOT]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 29; CHECK-NEXT: br label [[TMP10]] 30; CHECK: ret i32 0 31; 32entry: 33 %0 = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 34 %1 = add nsw <2 x i64> %0, <i64 1, i64 1> 35 store <2 x i64> %1, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 36 %2 = load i64, i64* @m, align 8 37 %and = and i64 %2, 1 38 %tobool = icmp eq i64 %and, 0 39 br i1 %tobool, label %if.end, label %if.then 40 41if.then: ; preds = %entry 42 %3 = add nsw <2 x i64> %0, <i64 2, i64 2> 43 store <2 x i64> %3, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 44 br label %if.end 45 46if.end: ; preds = %entry, %if.then 47 %4 = phi <2 x i64> [ %1, %entry ], [ %3, %if.then ] 48 %and4 = and i64 %2, 2 49 %tobool5 = icmp eq i64 %and4, 0 50 br i1 %tobool5, label %if.end9, label %if.then6 51 52if.then6: ; preds = %if.end 53 %5 = add nsw <2 x i64> %4, <i64 1, i64 1> 54 store <2 x i64> %5, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 55 br label %if.end9 56 57if.end9: ; preds = %if.end, %if.then6 58 ret i32 0 59} 60 61define i32 @align_not_equal() local_unnamed_addr { 62; CHECK-LABEL: @align_not_equal( 63; CHECK-NEXT: entry: 64; CHECK-NEXT: [[TMP0:%.*]] = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 65; CHECK-NEXT: [[TMP1:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 1, i64 1> 66; CHECK-NEXT: store <2 x i64> [[TMP1]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 67; CHECK-NEXT: [[TMP2:%.*]] = load i64, i64* @m, align 8 68; CHECK-NEXT: [[AND:%.*]] = and i64 [[TMP2]], 1 69; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i64 [[AND]], 0 70; CHECK-NEXT: [[TMP3:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 2, i64 2> 71; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TOBOOL]], <2 x i64> [[TMP1]], <2 x i64> [[TMP3]] 72; CHECK-NEXT: [[AND4:%.*]] = and i64 [[TMP2]], 2 73; CHECK-NEXT: [[TOBOOL5:%.*]] = icmp eq i64 [[AND4]], 0 74; CHECK-NEXT: [[TMP5:%.*]] = add nsw <2 x i64> [[TMP4]], <i64 1, i64 1> 75; CHECK-NEXT: [[DOT:%.*]] = select i1 [[TOBOOL5]], <2 x i64> [[TMP4]], <2 x i64> [[TMP5]] 76; CHECK-NEXT: [[TMP6:%.*]] = xor i1 [[TOBOOL]], true 77; CHECK-NEXT: [[TMP7:%.*]] = xor i1 [[TOBOOL5]], true 78; CHECK-NEXT: [[TMP8:%.*]] = or i1 [[TMP6]], [[TMP7]] 79; CHECK-NEXT: br i1 [[TMP8]], label [[TMP9:%.*]], label [[TMP10:%.*]] 80; CHECK: store <2 x i64> [[DOT]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 81; CHECK-NEXT: br label [[TMP10]] 82; CHECK: ret i32 0 83; 84entry: 85 %0 = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 86 %1 = add nsw <2 x i64> %0, <i64 1, i64 1> 87 store <2 x i64> %1, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 88 %2 = load i64, i64* @m, align 8 89 %and = and i64 %2, 1 90 %tobool = icmp eq i64 %and, 0 91 br i1 %tobool, label %if.end, label %if.then 92 93if.then: ; preds = %entry 94 %3 = add nsw <2 x i64> %0, <i64 2, i64 2> 95 store <2 x i64> %3, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 16 96 br label %if.end 97 98if.end: ; preds = %entry, %if.then 99 %4 = phi <2 x i64> [ %1, %entry ], [ %3, %if.then ] 100 %and4 = and i64 %2, 2 101 %tobool5 = icmp eq i64 %and4, 0 102 br i1 %tobool5, label %if.end9, label %if.then6 103 104if.then6: ; preds = %if.end 105 %5 = add nsw <2 x i64> %4, <i64 1, i64 1> 106 store <2 x i64> %5, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 107 br label %if.end9 108 109if.end9: ; preds = %if.end, %if.then6 110 ret i32 0 111} 112 113define i32 @align_single_zero() local_unnamed_addr { 114; CHECK-LABEL: @align_single_zero( 115; CHECK-NEXT: entry: 116; CHECK-NEXT: [[TMP0:%.*]] = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 117; CHECK-NEXT: [[TMP1:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 1, i64 1> 118; CHECK-NEXT: store <2 x i64> [[TMP1]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 119; CHECK-NEXT: [[TMP2:%.*]] = load i64, i64* @m, align 8 120; CHECK-NEXT: [[AND:%.*]] = and i64 [[TMP2]], 1 121; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i64 [[AND]], 0 122; CHECK-NEXT: [[TMP3:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 2, i64 2> 123; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TOBOOL]], <2 x i64> [[TMP1]], <2 x i64> [[TMP3]] 124; CHECK-NEXT: [[AND4:%.*]] = and i64 [[TMP2]], 2 125; CHECK-NEXT: [[TOBOOL5:%.*]] = icmp eq i64 [[AND4]], 0 126; CHECK-NEXT: [[TMP5:%.*]] = add nsw <2 x i64> [[TMP4]], <i64 1, i64 1> 127; CHECK-NEXT: [[DOT:%.*]] = select i1 [[TOBOOL5]], <2 x i64> [[TMP4]], <2 x i64> [[TMP5]] 128; CHECK-NEXT: [[TMP6:%.*]] = xor i1 [[TOBOOL]], true 129; CHECK-NEXT: [[TMP7:%.*]] = xor i1 [[TOBOOL5]], true 130; CHECK-NEXT: [[TMP8:%.*]] = or i1 [[TMP6]], [[TMP7]] 131; CHECK-NEXT: br i1 [[TMP8]], label [[TMP9:%.*]], label [[TMP10:%.*]] 132; CHECK: store <2 x i64> [[DOT]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 133; CHECK-NEXT: br label [[TMP10]] 134; CHECK: ret i32 0 135; 136entry: 137 %0 = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 138 %1 = add nsw <2 x i64> %0, <i64 1, i64 1> 139 store <2 x i64> %1, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 140 %2 = load i64, i64* @m, align 8 141 %and = and i64 %2, 1 142 %tobool = icmp eq i64 %and, 0 143 br i1 %tobool, label %if.end, label %if.then 144 145if.then: ; preds = %entry 146 %3 = add nsw <2 x i64> %0, <i64 2, i64 2> 147 store <2 x i64> %3, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*) 148 br label %if.end 149 150if.end: ; preds = %entry, %if.then 151 %4 = phi <2 x i64> [ %1, %entry ], [ %3, %if.then ] 152 %and4 = and i64 %2, 2 153 %tobool5 = icmp eq i64 %and4, 0 154 br i1 %tobool5, label %if.end9, label %if.then6 155 156if.then6: ; preds = %if.end 157 %5 = add nsw <2 x i64> %4, <i64 1, i64 1> 158 store <2 x i64> %5, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 159 br label %if.end9 160 161if.end9: ; preds = %if.end, %if.then6 162 ret i32 0 163} 164 165define i32 @align_single_zero_second_greater_default() local_unnamed_addr { 166; CHECK-LABEL: @align_single_zero_second_greater_default( 167; CHECK-NEXT: entry: 168; CHECK-NEXT: [[TMP0:%.*]] = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 169; CHECK-NEXT: [[TMP1:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 1, i64 1> 170; CHECK-NEXT: store <2 x i64> [[TMP1]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 171; CHECK-NEXT: [[TMP2:%.*]] = load i64, i64* @m, align 8 172; CHECK-NEXT: [[AND:%.*]] = and i64 [[TMP2]], 1 173; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i64 [[AND]], 0 174; CHECK-NEXT: [[TMP3:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 2, i64 2> 175; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TOBOOL]], <2 x i64> [[TMP1]], <2 x i64> [[TMP3]] 176; CHECK-NEXT: [[AND4:%.*]] = and i64 [[TMP2]], 2 177; CHECK-NEXT: [[TOBOOL5:%.*]] = icmp eq i64 [[AND4]], 0 178; CHECK-NEXT: [[TMP5:%.*]] = add nsw <2 x i64> [[TMP4]], <i64 1, i64 1> 179; CHECK-NEXT: [[DOT:%.*]] = select i1 [[TOBOOL5]], <2 x i64> [[TMP4]], <2 x i64> [[TMP5]] 180; CHECK-NEXT: [[TMP6:%.*]] = xor i1 [[TOBOOL]], true 181; CHECK-NEXT: [[TMP7:%.*]] = xor i1 [[TOBOOL5]], true 182; CHECK-NEXT: [[TMP8:%.*]] = or i1 [[TMP6]], [[TMP7]] 183; CHECK-NEXT: br i1 [[TMP8]], label [[TMP9:%.*]], label [[TMP10:%.*]] 184; CHECK: store <2 x i64> [[DOT]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 16 185; CHECK-NEXT: br label [[TMP10]] 186; CHECK: ret i32 0 187; 188entry: 189 %0 = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 190 %1 = add nsw <2 x i64> %0, <i64 1, i64 1> 191 store <2 x i64> %1, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 192 %2 = load i64, i64* @m, align 8 193 %and = and i64 %2, 1 194 %tobool = icmp eq i64 %and, 0 195 br i1 %tobool, label %if.end, label %if.then 196 197if.then: ; preds = %entry 198 %3 = add nsw <2 x i64> %0, <i64 2, i64 2> 199 store <2 x i64> %3, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 32 200 br label %if.end 201 202if.end: ; preds = %entry, %if.then 203 %4 = phi <2 x i64> [ %1, %entry ], [ %3, %if.then ] 204 %and4 = and i64 %2, 2 205 %tobool5 = icmp eq i64 %and4, 0 206 br i1 %tobool5, label %if.end9, label %if.then6 207 208if.then6: ; preds = %if.end 209 %5 = add nsw <2 x i64> %4, <i64 1, i64 1> 210 store <2 x i64> %5, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*) 211 br label %if.end9 212 213if.end9: ; preds = %if.end, %if.then6 214 ret i32 0 215} 216 217define i32 @align_both_zero() local_unnamed_addr { 218; CHECK-LABEL: @align_both_zero( 219; CHECK-NEXT: entry: 220; CHECK-NEXT: [[TMP0:%.*]] = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 221; CHECK-NEXT: [[TMP1:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 1, i64 1> 222; CHECK-NEXT: store <2 x i64> [[TMP1]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 223; CHECK-NEXT: [[TMP2:%.*]] = load i64, i64* @m, align 8 224; CHECK-NEXT: [[AND:%.*]] = and i64 [[TMP2]], 1 225; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i64 [[AND]], 0 226; CHECK-NEXT: [[TMP3:%.*]] = add nsw <2 x i64> [[TMP0]], <i64 2, i64 2> 227; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TOBOOL]], <2 x i64> [[TMP1]], <2 x i64> [[TMP3]] 228; CHECK-NEXT: [[AND4:%.*]] = and i64 [[TMP2]], 2 229; CHECK-NEXT: [[TOBOOL5:%.*]] = icmp eq i64 [[AND4]], 0 230; CHECK-NEXT: [[TMP5:%.*]] = add nsw <2 x i64> [[TMP4]], <i64 1, i64 1> 231; CHECK-NEXT: [[DOT:%.*]] = select i1 [[TOBOOL5]], <2 x i64> [[TMP4]], <2 x i64> [[TMP5]] 232; CHECK-NEXT: [[TMP6:%.*]] = xor i1 [[TOBOOL]], true 233; CHECK-NEXT: [[TMP7:%.*]] = xor i1 [[TOBOOL5]], true 234; CHECK-NEXT: [[TMP8:%.*]] = or i1 [[TMP6]], [[TMP7]] 235; CHECK-NEXT: br i1 [[TMP8]], label [[TMP9:%.*]], label [[TMP10:%.*]] 236; CHECK: store <2 x i64> [[DOT]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 16 237; CHECK-NEXT: br label [[TMP10]] 238; CHECK: ret i32 0 239; 240entry: 241 %0 = load <2 x i64>, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 242 %1 = add nsw <2 x i64> %0, <i64 1, i64 1> 243 store <2 x i64> %1, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8 244 %2 = load i64, i64* @m, align 8 245 %and = and i64 %2, 1 246 %tobool = icmp eq i64 %and, 0 247 br i1 %tobool, label %if.end, label %if.then 248 249if.then: ; preds = %entry 250 %3 = add nsw <2 x i64> %0, <i64 2, i64 2> 251 store <2 x i64> %3, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*) 252 br label %if.end 253 254if.end: ; preds = %entry, %if.then 255 %4 = phi <2 x i64> [ %1, %entry ], [ %3, %if.then ] 256 %and4 = and i64 %2, 2 257 %tobool5 = icmp eq i64 %and4, 0 258 br i1 %tobool5, label %if.end9, label %if.then6 259 260if.then6: ; preds = %if.end 261 %5 = add nsw <2 x i64> %4, <i64 1, i64 1> 262 store <2 x i64> %5, <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*) 263 br label %if.end9 264 265if.end9: ; preds = %if.end, %if.then6 266 ret i32 0 267} 268