1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s --data-layout "e" -dse -enable-dse-partial-store-merging=true -S | FileCheck %s
3; RUN: opt < %s --data-layout "E" -dse -enable-dse-partial-store-merging=true -S | FileCheck %s
4
5; This test used to hit an assertion (see PR41949).
6;
7; Better safe than sorry, do not assume anything about the padding for the
8; i28 store that has 32 bits as store size.
9define void @test1(i32* %p) {
10; CHECK-LABEL: @test1(
11; CHECK-NEXT:    [[A:%.*]] = alloca i32
12; CHECK-NEXT:    [[B:%.*]] = bitcast i32* [[A]] to i28*
13; CHECK-NEXT:    [[C:%.*]] = bitcast i32* [[A]] to { i16, i16 }*
14; CHECK-NEXT:    [[C1:%.*]] = getelementptr inbounds { i16, i16 }, { i16, i16 }* [[C]], i32 0, i32 1
15; CHECK-NEXT:    store i28 10, i28* [[B]]
16; CHECK-NEXT:    store i16 20, i16* [[C1]]
17; CHECK-NEXT:    call void @test1(i32* [[A]])
18; CHECK-NEXT:    ret void
19;
20  %a = alloca i32
21  %b = bitcast i32* %a to i28*
22  %c = bitcast i32* %a to { i16, i16 }*
23  %c1 = getelementptr inbounds { i16, i16 }, { i16, i16 }* %c, i32 0, i32 1
24  store i28 10, i28* %b
25  store i16 20, i16* %c1
26
27  call void @test1(i32* %a)
28  ret void
29}
30
31
32; This test used to mis-compile (see PR41949).
33;
34; Better safe than sorry, do not assume anything about the padding for the
35; i12 store that has 16 bits as store size.
36define void @test2(i32* %p) {
37; CHECK-LABEL: @test2(
38; CHECK-NEXT:    [[U:%.*]] = alloca i32
39; CHECK-NEXT:    [[A:%.*]] = bitcast i32* [[U]] to i32*
40; CHECK-NEXT:    [[B:%.*]] = bitcast i32* [[U]] to i12*
41; CHECK-NEXT:    store i32 -1, i32* [[A]]
42; CHECK-NEXT:    store i12 20, i12* [[B]]
43; CHECK-NEXT:    call void @test2(i32* [[U]])
44; CHECK-NEXT:    ret void
45;
46  %u = alloca i32
47  %a = bitcast i32* %u to i32*
48  %b = bitcast i32* %u to i12*
49  store i32 -1, i32* %a
50  store i12 20, i12* %b
51
52  call void @test2(i32* %u)
53  ret void
54}
55
56