; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -O3 -S | FileCheck %s
target triple = "x86_64-unknown-linux-gnu"
%struct.data_t = type { [16 x i8] }
declare void @process6data_t(i64, i64)
declare void @process36data_tS_S_(i64, i64, i64, i64, i64, i64)
; See https://llvm.org/PR47023 for source examples.
; In all tests, we expect the i8 constant stores to get merged optimally
; (through SROA, combining, etc.) so that there are no store insts left.
define void @bad1() {
; CHECK-LABEL: @bad1(
; CHECK-NEXT: bb:
; CHECK-NEXT: tail call void @process6data_t(i64 21542142465, i64 0)
; CHECK-NEXT: ret void
;
bb:
%i = alloca %struct.data_t, align 1
store i8 1, ptr %i, align 1
%i3 = getelementptr inbounds i8, ptr %i, i64 1
store i8 2, ptr %i3, align 1
%i4 = getelementptr inbounds i8, ptr %i3, i64 1
store i8 3, ptr %i4, align 1
%i5 = getelementptr inbounds i8, ptr %i4, i64 1
store i8 4, ptr %i5, align 1
%i6 = getelementptr inbounds i8, ptr %i5, i64 1
store i8 5, ptr %i6, align 1
%i7 = getelementptr inbounds i8, ptr %i6, i64 1
%i8 = getelementptr inbounds i8, ptr %i, i64 16
br label %bb9
bb9: ; preds = %bb9, %bb
%i10 = phi ptr [ %i7, %bb ], [ %i11, %bb9 ]
store i8 0, ptr %i10, align 1
%i11 = getelementptr inbounds i8, ptr %i10, i64 1
%i12 = icmp eq ptr %i11, %i8
br i1 %i12, label %bb13, label %bb9
bb13: ; preds = %bb9
%i15 = getelementptr inbounds { i64, i64 }, ptr %i, i32 0, i32 0
%i16 = load i64, ptr %i15, align 1
%i17 = getelementptr inbounds { i64, i64 }, ptr %i, i32 0, i32 1
%i18 = load i64, ptr %i17, align 1
call void @process6data_t(i64 %i16, i64 %i18)
ret void
}
define void @bad2() {
; CHECK-LABEL: @bad2(
; CHECK-NEXT: bb:
; CHECK-NEXT: tail call void @process6data_t(i64 216736853120975361, i64 1411785848587524)
; CHECK-NEXT: ret void
;
bb:
%i = alloca %struct.data_t, align 1
store i8 1, ptr %i, align 1
%i3 = getelementptr inbounds i8, ptr %i, i64 1
store i8 2, ptr %i3, align 1
%i4 = getelementptr inbounds i8, ptr %i3, i64 1
store i8 3, ptr %i4, align 1
%i5 = getelementptr inbounds i8, ptr %i4, i64 1
store i8 4, ptr %i5, align 1
%i6 = getelementptr inbounds i8, ptr %i5, i64 1
store i8 5, ptr %i6, align 1
%i7 = getelementptr inbounds i8, ptr %i6, i64 1
store i8 1, ptr %i7, align 1
%i8 = getelementptr inbounds i8, ptr %i7, i64 1
store i8 2, ptr %i8, align 1
%i9 = getelementptr inbounds i8, ptr %i8, i64 1
store i8 3, ptr %i9, align 1
%i10 = getelementptr inbounds i8, ptr %i9, i64 1
store i8 4, ptr %i10, align 1
%i11 = getelementptr inbounds i8, ptr %i10, i64 1
store i8 5, ptr %i11, align 1
%i12 = getelementptr inbounds i8, ptr %i11, i64 1
store i8 1, ptr %i12, align 1
%i13 = getelementptr inbounds i8, ptr %i12, i64 1
store i8 2, ptr %i13, align 1
%i14 = getelementptr inbounds i8, ptr %i13, i64 1
store i8 3, ptr %i14, align 1
%i15 = getelementptr inbounds i8, ptr %i14, i64 1
store i8 4, ptr %i15, align 1
%i16 = getelementptr inbounds i8, ptr %i15, i64 1
store i8 5, ptr %i16, align 1
%i17 = getelementptr inbounds i8, ptr %i16, i64 1
%i18 = getelementptr inbounds i8, ptr %i, i64 16
br label %bb19
bb19: ; preds = %bb19, %bb
%i20 = phi ptr [ %i17, %bb ], [ %i21, %bb19 ]
store i8 0, ptr %i20, align 1
%i21 = getelementptr inbounds i8, ptr %i20, i64 1
%i22 = icmp eq ptr %i21, %i18
br i1 %i22, label %bb23, label %bb19
bb23: ; preds = %bb19
%i25 = getelementptr inbounds { i64, i64 }, ptr %i, i32 0, i32 0
%i26 = load i64, ptr %i25, align 1
%i27 = getelementptr inbounds { i64, i64 }, ptr %i, i32 0, i32 1
%i28 = load i64, ptr %i27, align 1
call void @process6data_t(i64 %i26, i64 %i28)
ret void
}
define void @bad3() {
; CHECK-LABEL: @bad3(
; CHECK-NEXT: bb:
; CHECK-NEXT: tail call void @process36data_tS_S_(i64 21542142465, i64 0, i64 723401749922909195, i64 723401728380766730, i64 1446803478303675925, i64 5651576002974730)
; CHECK-NEXT: ret void
;
bb:
%i = alloca %struct.data_t, align 1
%i1 = alloca %struct.data_t, align 1
%i2 = alloca %struct.data_t, align 1
store i8 1, ptr %i, align 1
%i5 = getelementptr inbounds i8, ptr %i, i64 1
store i8 2, ptr %i5, align 1
%i6 = getelementptr inbounds i8, ptr %i5, i64 1
store i8 3, ptr %i6, align 1
%i7 = getelementptr inbounds i8, ptr %i6, i64 1
store i8 4, ptr %i7, align 1
%i8 = getelementptr inbounds i8, ptr %i7, i64 1
store i8 5, ptr %i8, align 1
%i9 = getelementptr inbounds i8, ptr %i8, i64 1
store i8 0, ptr %i9, align 1
%i10 = getelementptr inbounds i8, ptr %i9, i64 1
store i8 0, ptr %i10, align 1
%i11 = getelementptr inbounds i8, ptr %i10, i64 1
store i8 0, ptr %i11, align 1
%i12 = getelementptr inbounds i8, ptr %i11, i64 1
store i8 0, ptr %i12, align 1
%i13 = getelementptr inbounds i8, ptr %i12, i64 1
store i8 0, ptr %i13, align 1
%i14 = getelementptr inbounds i8, ptr %i13, i64 1
store i8 0, ptr %i14, align 1
%i15 = getelementptr inbounds i8, ptr %i14, i64 1
store i8 0, ptr %i15, align 1
%i16 = getelementptr inbounds i8, ptr %i15, i64 1
store i8 0, ptr %i16, align 1
%i17 = getelementptr inbounds i8, ptr %i16, i64 1
store i8 0, ptr %i17, align 1
%i18 = getelementptr inbounds i8, ptr %i17, i64 1
store i8 0, ptr %i18, align 1
%i19 = getelementptr inbounds i8, ptr %i18, i64 1
store i8 0, ptr %i19, align 1
store i8 11, ptr %i1, align 1
%i22 = getelementptr inbounds i8, ptr %i1, i64 1
store i8 12, ptr %i22, align 1
%i23 = getelementptr inbounds i8, ptr %i22, i64 1
store i8 13, ptr %i23, align 1
%i24 = getelementptr inbounds i8, ptr %i23, i64 1
store i8 14, ptr %i24, align 1
%i25 = getelementptr inbounds i8, ptr %i24, i64 1
store i8 15, ptr %i25, align 1
%i26 = getelementptr inbounds i8, ptr %i25, i64 1
store i8 10, ptr %i26, align 1
%i27 = getelementptr inbounds i8, ptr %i26, i64 1
store i8 10, ptr %i27, align 1
%i28 = getelementptr inbounds i8, ptr %i27, i64 1
store i8 10, ptr %i28, align 1
%i29 = getelementptr inbounds i8, ptr %i28, i64 1
store i8 10, ptr %i29, align 1
%i30 = getelementptr inbounds i8, ptr %i29, i64 1
store i8 10, ptr %i30, align 1
%i31 = getelementptr inbounds i8, ptr %i30, i64 1
store i8 10, ptr %i31, align 1
%i32 = getelementptr inbounds i8, ptr %i31, i64 1
store i8 10, ptr %i32, align 1
%i33 = getelementptr inbounds i8, ptr %i32, i64 1
store i8 10, ptr %i33, align 1
%i34 = getelementptr inbounds i8, ptr %i33, i64 1
store i8 10, ptr %i34, align 1
%i35 = getelementptr inbounds i8, ptr %i34, i64 1
store i8 10, ptr %i35, align 1
%i36 = getelementptr inbounds i8, ptr %i35, i64 1
store i8 10, ptr %i36, align 1
store i8 21, ptr %i2, align 1
%i39 = getelementptr inbounds i8, ptr %i2, i64 1
store i8 22, ptr %i39, align 1
%i40 = getelementptr inbounds i8, ptr %i39, i64 1
store i8 23, ptr %i40, align 1
%i41 = getelementptr inbounds i8, ptr %i40, i64 1
store i8 24, ptr %i41, align 1
%i42 = getelementptr inbounds i8, ptr %i41, i64 1
store i8 25, ptr %i42, align 1
%i43 = getelementptr inbounds i8, ptr %i42, i64 1
store i8 20, ptr %i43, align 1
%i44 = getelementptr inbounds i8, ptr %i43, i64 1
store i8 20, ptr %i44, align 1
%i45 = getelementptr inbounds i8, ptr %i44, i64 1
store i8 20, ptr %i45, align 1
%i46 = getelementptr inbounds i8, ptr %i45, i64 1
store i8 10, ptr %i46, align 1
%i47 = getelementptr inbounds i8, ptr %i46, i64 1
store i8 20, ptr %i47, align 1
%i48 = getelementptr inbounds i8, ptr %i47, i64 1
store i8 20, ptr %i48, align 1
%i49 = getelementptr inbounds i8, ptr %i48, i64 1
store i8 20, ptr %i49, align 1
%i50 = getelementptr inbounds i8, ptr %i49, i64 1
store i8 20, ptr %i50, align 1
%i51 = getelementptr inbounds i8, ptr %i50, i64 1
store i8 20, ptr %i51, align 1
%i52 = getelementptr inbounds i8, ptr %i51, i64 1
store i8 20, ptr %i52, align 1
%i53 = getelementptr inbounds i8, ptr %i52, i64 1
%i54 = getelementptr inbounds i8, ptr %i2, i64 16
br label %bb55
bb55: ; preds = %bb55, %bb
%i56 = phi ptr [ %i53, %bb ], [ %i57, %bb55 ]
store i8 0, ptr %i56, align 1
%i57 = getelementptr inbounds i8, ptr %i56, i64 1
%i58 = icmp eq ptr %i57, %i54
br i1 %i58, label %bb59, label %bb55
bb59: ; preds = %bb55
%i61 = getelementptr inbounds { i64, i64 }, ptr %i, i32 0, i32 0
%i62 = load i64, ptr %i61, align 1
%i63 = getelementptr inbounds { i64, i64 }, ptr %i, i32 0, i32 1
%i64 = load i64, ptr %i63, align 1
%i66 = getelementptr inbounds { i64, i64 }, ptr %i1, i32 0, i32 0
%i67 = load i64, ptr %i66, align 1
%i68 = getelementptr inbounds { i64, i64 }, ptr %i1, i32 0, i32 1
%i69 = load i64, ptr %i68, align 1
%i71 = getelementptr inbounds { i64, i64 }, ptr %i2, i32 0, i32 0
%i72 = load i64, ptr %i71, align 1
%i73 = getelementptr inbounds { i64, i64 }, ptr %i2, i32 0, i32 1
%i74 = load i64, ptr %i73, align 1
call void @process36data_tS_S_(i64 %i62, i64 %i64, i64 %i67, i64 %i69, i64 %i72, i64 %i74)
ret void
}
define void @bad4() {
; CHECK-LABEL: @bad4(
; CHECK-NEXT: bb:
; CHECK-NEXT: tail call void @process36data_tS_S_(i64 21542142465, i64 0, i64 723401749922909195, i64 723401728380766730, i64 1446803478303675925, i64 798285110420182026)
; CHECK-NEXT: ret void
;
bb:
%i = alloca %struct.data_t, align 1
%i1 = alloca %struct.data_t, align 1
%i2 = alloca %struct.data_t, align 1
store i8 1, ptr %i, align 1
%i5 = getelementptr inbounds i8, ptr %i, i64 1
store i8 2, ptr %i5, align 1
%i6 = getelementptr inbounds i8, ptr %i5, i64 1
store i8 3, ptr %i6, align 1
%i7 = getelementptr inbounds i8, ptr %i6, i64 1
store i8 4, ptr %i7, align 1
%i8 = getelementptr inbounds i8, ptr %i7, i64 1
store i8 5, ptr %i8, align 1
%i9 = getelementptr inbounds i8, ptr %i8, i64 1
store i8 0, ptr %i9, align 1
%i10 = getelementptr inbounds i8, ptr %i9, i64 1
store i8 0, ptr %i10, align 1
%i11 = getelementptr inbounds i8, ptr %i10, i64 1
store i8 0, ptr %i11, align 1
%i12 = getelementptr inbounds i8, ptr %i11, i64 1
store i8 0, ptr %i12, align 1
%i13 = getelementptr inbounds i8, ptr %i12, i64 1
store i8 0, ptr %i13, align 1
%i14 = getelementptr inbounds i8, ptr %i13, i64 1
store i8 0, ptr %i14, align 1
%i15 = getelementptr inbounds i8, ptr %i14, i64 1
store i8 0, ptr %i15, align 1
%i16 = getelementptr inbounds i8, ptr %i15, i64 1
store i8 0, ptr %i16, align 1
%i17 = getelementptr inbounds i8, ptr %i16, i64 1
store i8 0, ptr %i17, align 1
%i18 = getelementptr inbounds i8, ptr %i17, i64 1
store i8 0, ptr %i18, align 1
%i19 = getelementptr inbounds i8, ptr %i18, i64 1
store i8 0, ptr %i19, align 1
store i8 11, ptr %i1, align 1
%i22 = getelementptr inbounds i8, ptr %i1, i64 1
store i8 12, ptr %i22, align 1
%i23 = getelementptr inbounds i8, ptr %i22, i64 1
store i8 13, ptr %i23, align 1
%i24 = getelementptr inbounds i8, ptr %i23, i64 1
store i8 14, ptr %i24, align 1
%i25 = getelementptr inbounds i8, ptr %i24, i64 1
store i8 15, ptr %i25, align 1
%i26 = getelementptr inbounds i8, ptr %i25, i64 1
store i8 10, ptr %i26, align 1
%i27 = getelementptr inbounds i8, ptr %i26, i64 1
store i8 10, ptr %i27, align 1
%i28 = getelementptr inbounds i8, ptr %i27, i64 1
store i8 10, ptr %i28, align 1
%i29 = getelementptr inbounds i8, ptr %i28, i64 1
store i8 10, ptr %i29, align 1
%i30 = getelementptr inbounds i8, ptr %i29, i64 1
store i8 10, ptr %i30, align 1
%i31 = getelementptr inbounds i8, ptr %i30, i64 1
store i8 10, ptr %i31, align 1
%i32 = getelementptr inbounds i8, ptr %i31, i64 1
store i8 10, ptr %i32, align 1
%i33 = getelementptr inbounds i8, ptr %i32, i64 1
store i8 10, ptr %i33, align 1
%i34 = getelementptr inbounds i8, ptr %i33, i64 1
store i8 10, ptr %i34, align 1
%i35 = getelementptr inbounds i8, ptr %i34, i64 1
store i8 10, ptr %i35, align 1
%i36 = getelementptr inbounds i8, ptr %i35, i64 1
store i8 10, ptr %i36, align 1
store i8 21, ptr %i2, align 1
%i39 = getelementptr inbounds i8, ptr %i2, i64 1
store i8 22, ptr %i39, align 1
%i40 = getelementptr inbounds i8, ptr %i39, i64 1
store i8 23, ptr %i40, align 1
%i41 = getelementptr inbounds i8, ptr %i40, i64 1
store i8 24, ptr %i41, align 1
%i42 = getelementptr inbounds i8, ptr %i41, i64 1
store i8 25, ptr %i42, align 1
%i43 = getelementptr inbounds i8, ptr %i42, i64 1
store i8 20, ptr %i43, align 1
%i44 = getelementptr inbounds i8, ptr %i43, i64 1
store i8 20, ptr %i44, align 1
%i45 = getelementptr inbounds i8, ptr %i44, i64 1
store i8 20, ptr %i45, align 1
%i46 = getelementptr inbounds i8, ptr %i45, i64 1
store i8 10, ptr %i46, align 1
%i47 = getelementptr inbounds i8, ptr %i46, i64 1
store i8 20, ptr %i47, align 1
%i48 = getelementptr inbounds i8, ptr %i47, i64 1
store i8 20, ptr %i48, align 1
%i49 = getelementptr inbounds i8, ptr %i48, i64 1
store i8 20, ptr %i49, align 1
%i50 = getelementptr inbounds i8, ptr %i49, i64 1
store i8 20, ptr %i50, align 1
%i51 = getelementptr inbounds i8, ptr %i50, i64 1
store i8 20, ptr %i51, align 1
%i52 = getelementptr inbounds i8, ptr %i51, i64 1
store i8 20, ptr %i52, align 1
%i53 = getelementptr inbounds i8, ptr %i52, i64 1
store i8 11, ptr %i53, align 1
%i55 = getelementptr inbounds { i64, i64 }, ptr %i, i32 0, i32 0
%i56 = load i64, ptr %i55, align 1
%i57 = getelementptr inbounds { i64, i64 }, ptr %i, i32 0, i32 1
%i58 = load i64, ptr %i57, align 1
%i60 = getelementptr inbounds { i64, i64 }, ptr %i1, i32 0, i32 0
%i61 = load i64, ptr %i60, align 1
%i62 = getelementptr inbounds { i64, i64 }, ptr %i1, i32 0, i32 1
%i63 = load i64, ptr %i62, align 1
%i65 = getelementptr inbounds { i64, i64 }, ptr %i2, i32 0, i32 0
%i66 = load i64, ptr %i65, align 1
%i67 = getelementptr inbounds { i64, i64 }, ptr %i2, i32 0, i32 1
%i68 = load i64, ptr %i67, align 1
call void @process36data_tS_S_(i64 %i56, i64 %i58, i64 %i61, i64 %i63, i64 %i66, i64 %i68)
ret void
}