1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -instcombine -instcombine-infinite-loop-threshold=3 -S | FileCheck %s 3 4@var_7 = external global i8, align 1 5@var_1 = external global i32, align 4 6@var_0 = external global i16, align 2 7@var_5 = external global i64, align 8 8@arr_2 = external global [0 x i32], align 4 9@arr_4 = external global [0 x i16], align 2 10@arr_3 = external global [8 x i32], align 16 11 12define void @_Z4testv() { 13; CHECK-LABEL: @_Z4testv( 14; CHECK-NEXT: bb: 15; CHECK-NEXT: [[I:%.*]] = load i8, i8* @var_7, align 1 16; CHECK-NEXT: [[I1:%.*]] = icmp eq i8 [[I]], -1 17; CHECK-NEXT: [[I4:%.*]] = load i16, i16* @var_0, align 2 18; CHECK-NEXT: [[I8:%.*]] = sext i16 [[I4]] to i32 19; CHECK-NEXT: br i1 [[I1]], label [[BB10:%.*]], label [[BB9:%.*]] 20; CHECK: bb9: 21; CHECK-NEXT: br label [[BB12:%.*]] 22; CHECK: bb10: 23; CHECK-NEXT: [[I2:%.*]] = load i32, i32* @var_1, align 4 24; CHECK-NEXT: [[I3:%.*]] = icmp eq i32 [[I2]], 0 25; CHECK-NEXT: [[I6:%.*]] = load i64, i64* @var_5, align 8 26; CHECK-NEXT: [[I5:%.*]] = sext i16 [[I4]] to i64 27; CHECK-NEXT: [[I7:%.*]] = select i1 [[I3]], i64 [[I6]], i64 [[I5]] 28; CHECK-NEXT: [[I11:%.*]] = trunc i64 [[I7]] to i32 29; CHECK-NEXT: br label [[BB12]] 30; CHECK: bb12: 31; CHECK-NEXT: [[STOREMERGE1:%.*]] = phi i32 [ [[I11]], [[BB10]] ], [ 1, [[BB9]] ] 32; CHECK-NEXT: store i32 [[STOREMERGE1]], i32* getelementptr inbounds ([0 x i32], [0 x i32]* @arr_2, i64 0, i64 0), align 4 33; CHECK-NEXT: store i16 [[I4]], i16* getelementptr inbounds ([0 x i16], [0 x i16]* @arr_4, i64 0, i64 0), align 2 34; CHECK-NEXT: store i32 [[I8]], i32* getelementptr inbounds ([8 x i32], [8 x i32]* @arr_3, i64 0, i64 0), align 16 35; CHECK-NEXT: store i32 [[STOREMERGE1]], i32* getelementptr inbounds ([0 x i32], [0 x i32]* @arr_2, i64 0, i64 1), align 4 36; CHECK-NEXT: store i16 [[I4]], i16* getelementptr inbounds ([0 x i16], [0 x i16]* @arr_4, i64 0, i64 1), align 2 37; CHECK-NEXT: store i32 [[I8]], i32* getelementptr inbounds ([8 x i32], [8 x i32]* @arr_3, i64 0, i64 1), align 4 38; CHECK-NEXT: ret void 39; 40bb: 41 %i = load i8, i8* @var_7, align 1 42 %i1 = icmp eq i8 %i, -1 43 %i2 = load i32, i32* @var_1, align 4 44 %i3 = icmp eq i32 %i2, 0 45 %i4 = load i16, i16* @var_0, align 2 46 %i5 = sext i16 %i4 to i64 47 %i6 = load i64, i64* @var_5, align 8 48 %i7 = select i1 %i3, i64 %i6, i64 %i5 49 %i8 = sext i16 %i4 to i32 50 br i1 %i1, label %bb10, label %bb9 51 52bb9: ; preds = %bb 53 store i32 1, i32* getelementptr inbounds ([0 x i32], [0 x i32]* @arr_2, i64 0, i64 0), align 4 54 store i16 %i4, i16* getelementptr inbounds ([0 x i16], [0 x i16]* @arr_4, i64 0, i64 0), align 2 55 store i32 %i8, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @arr_3, i64 0, i64 0), align 4 56 store i32 1, i32* getelementptr inbounds ([0 x i32], [0 x i32]* @arr_2, i64 0, i64 1), align 4 57 store i16 %i4, i16* getelementptr inbounds ([0 x i16], [0 x i16]* @arr_4, i64 0, i64 1), align 2 58 store i32 %i8, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @arr_3, i64 0, i64 1), align 4 59 br label %bb12 60 61bb10: ; preds = %bb 62 %i11 = trunc i64 %i7 to i32 63 store i32 %i11, i32* getelementptr inbounds ([0 x i32], [0 x i32]* @arr_2, i64 0, i64 0), align 4 64 store i16 %i4, i16* getelementptr inbounds ([0 x i16], [0 x i16]* @arr_4, i64 0, i64 0), align 2 65 store i32 %i8, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @arr_3, i64 0, i64 0), align 4 66 store i32 %i11, i32* getelementptr inbounds ([0 x i32], [0 x i32]* @arr_2, i64 0, i64 1), align 4 67 store i16 %i4, i16* getelementptr inbounds ([0 x i16], [0 x i16]* @arr_4, i64 0, i64 1), align 2 68 store i32 %i8, i32* getelementptr inbounds ([8 x i32], [8 x i32]* @arr_3, i64 0, i64 1), align 4 69 br label %bb12 70 71bb12: ; preds = %bb10, %bb9 72 ret void 73} 74