xref: /llvm-project/llvm/test/Transforms/DeadStoreElimination/PartialStore2.ll (revision f497a00da968b0ff90d8c98caa184d14b9a92495)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s --data-layout "e" -passes=dse -enable-dse-partial-store-merging=true -S | FileCheck %s
3; RUN: opt < %s --data-layout "E" -passes=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(ptr %p) {
10; CHECK-LABEL: @test1(
11; CHECK-NEXT:    [[A:%.*]] = alloca i32
12; CHECK-NEXT:    [[C1:%.*]] = getelementptr inbounds { i16, i16 }, ptr [[A]], i32 0, i32 1
13; CHECK-NEXT:    store i28 10, ptr [[A]]
14; CHECK-NEXT:    store i16 20, ptr [[C1]]
15; CHECK-NEXT:    call void @test1(ptr [[A]])
16; CHECK-NEXT:    ret void
17;
18  %a = alloca i32
19  %c1 = getelementptr inbounds { i16, i16 }, ptr %a, i32 0, i32 1
20  store i28 10, ptr %a
21  store i16 20, ptr %c1
22
23  call void @test1(ptr %a)
24  ret void
25}
26
27
28; This test used to mis-compile (see PR41949).
29;
30; Better safe than sorry, do not assume anything about the padding for the
31; i12 store that has 16 bits as store size.
32define void @test2(ptr %p) {
33; CHECK-LABEL: @test2(
34; CHECK-NEXT:    [[U:%.*]] = alloca i32
35; CHECK-NEXT:    store i32 -1, ptr [[U]]
36; CHECK-NEXT:    store i12 20, ptr [[U]]
37; CHECK-NEXT:    call void @test2(ptr [[U]])
38; CHECK-NEXT:    ret void
39;
40  %u = alloca i32
41  store i32 -1, ptr %u
42  store i12 20, ptr %u
43
44  call void @test2(ptr %u)
45  ret void
46}
47
48