xref: /llvm-project/llvm/test/CodeGen/AArch64/ldst-zero.ll (revision 5ddce70ef0e5a641d7fea95e31fc5e2439cb98cb)
1; RUN: llc -mtriple=aarch64 -mcpu=cortex-a53 < %s | FileCheck %s
2
3; Tests to check that zero stores which are generated as STP xzr, xzr aren't
4; scheduled incorrectly due to incorrect alias information
5
6declare void @llvm.memset.p0.i64(ptr nocapture, i8, i64, i1)
7%struct.tree_common = type { ptr, ptr, i32 }
8
9; Original test case which exhibited the bug
10define void @test1(ptr %t, i32 %code, ptr %type) {
11; CHECK-LABEL: test1:
12; CHECK-DAG: stp x2, xzr, [x0, #8]
13; CHECK-DAG: str w1, [x0, #16]
14; CHECK-DAG: str xzr, [x0]
15entry:
16  tail call void @llvm.memset.p0.i64(ptr align 8 %t, i8 0, i64 24, i1 false)
17  %code1 = getelementptr inbounds %struct.tree_common, ptr %t, i64 0, i32 2
18  store i32 %code, ptr %code1, align 8
19  %type2 = getelementptr inbounds %struct.tree_common, ptr %t, i64 0, i32 1
20  store ptr %type, ptr %type2, align 8
21  ret void
22}
23
24; Store to each struct element instead of using memset
25define void @test2(ptr %t, i32 %code, ptr %type) {
26; CHECK-LABEL: test2:
27; CHECK-DAG: str w1, [x0, #16]
28; CHECK-DAG: stp xzr, x2, [x0]
29entry:
30  %0 = getelementptr inbounds %struct.tree_common, ptr %t, i64 0, i32 1
31  %1 = getelementptr inbounds %struct.tree_common, ptr %t, i64 0, i32 2
32  store ptr zeroinitializer, ptr %t, align 8
33  store ptr zeroinitializer, ptr %0, align 8
34  store i32 zeroinitializer, ptr %1, align 8
35  store i32 %code, ptr %1, align 8
36  store ptr %type, ptr %0, align 8
37  ret void
38}
39
40; Vector store instead of memset
41define void @test3(ptr %t, i32 %code, ptr %type) {
42; CHECK-LABEL: test3:
43; CHECK-DAG: stp x2, xzr, [x0, #8]
44; CHECK-DAG: str w1, [x0, #16]
45; CHECK-DAG: str xzr, [x0]
46entry:
47  store <3 x i64> zeroinitializer, ptr %t, align 8
48  %code1 = getelementptr inbounds %struct.tree_common, ptr %t, i64 0, i32 2
49  store i32 %code, ptr %code1, align 8
50  %type2 = getelementptr inbounds %struct.tree_common, ptr %t, i64 0, i32 1
51  store ptr %type, ptr %type2, align 8
52  ret void
53}
54
55; Vector store, then store to vector elements
56define void @test4(ptr %p, i64 %x, i64 %y) {
57; CHECK-LABEL: test4:
58; CHECK-DAG: stp x2, x1, [x0, #8]
59; CHECK-DAG: str xzr, [x0]
60entry:
61  store <3 x i64> zeroinitializer, ptr %p, align 8
62  %0 = getelementptr inbounds i64, ptr %p, i64 2
63  store i64 %x, ptr %0, align 8
64  %1 = getelementptr inbounds i64, ptr %p, i64 1
65  store i64 %y, ptr %1, align 8
66  ret void
67}
68