xref: /llvm-project/llvm/test/CodeGen/AArch64/pr27816.ll (revision 5ddce70ef0e5a641d7fea95e31fc5e2439cb98cb)
1; RUN: llc %s -mtriple=aarch64 -o - | FileCheck %s
2
3%struct.A = type { i8, i8, i8, i8, i8, i8, i8, i8, i32 }
4
5; The existence of the final i32 value should not prevent the i8s from
6; being merged.
7
8; CHECK-LABEL: @merge_const_store
9; CHECK-NOT: strb
10; CHECK: str x8,  [x1]
11; CHECK-NOT: strb
12; CHECK: str wzr, [x1, #8]
13; CHECK-NOT: strb
14define void @merge_const_store(i32 %count, ptr nocapture %p)  {
15  %1 = icmp sgt i32 %count, 0
16  br i1 %1, label %.lr.ph, label %._crit_edge
17.lr.ph:
18  %i.02 = phi i32 [ %add, %.lr.ph ], [ 0, %0 ]
19  %.01 = phi ptr [ %addr, %.lr.ph ], [ %p, %0 ]
20  store i8 1, ptr %.01, align 1
21  %a3 = getelementptr inbounds %struct.A, ptr %.01, i64 0, i32 1
22  store i8 2, ptr %a3, align 1
23  %a4 = getelementptr inbounds %struct.A, ptr %.01, i64 0, i32 2
24  store i8 3, ptr %a4, align 1
25  %a5 = getelementptr inbounds %struct.A, ptr %.01, i64 0, i32 3
26  store i8 4, ptr %a5, align 1
27  %a6 = getelementptr inbounds %struct.A, ptr %.01, i64 0, i32 4
28  store i8 5, ptr %a6, align 1
29  %a7 = getelementptr inbounds %struct.A, ptr %.01, i64 0, i32 5
30  store i8 6, ptr %a7, align 1
31  %a8 = getelementptr inbounds %struct.A, ptr %.01, i64 0, i32 6
32  store i8 7, ptr %a8, align 1
33  %a9 = getelementptr inbounds %struct.A, ptr %.01, i64 0, i32 7
34  store i8 8, ptr %a9, align 1
35
36  ;
37  %addr_last = getelementptr inbounds %struct.A, ptr %.01, i64 0, i32 8
38  store i32 0, ptr %addr_last, align 4
39
40
41  %add = add nsw i32 %i.02, 1
42  %addr = getelementptr inbounds %struct.A, ptr %.01, i64 1
43  %exitcond = icmp eq i32 %add, %count
44  br i1 %exitcond, label %._crit_edge, label %.lr.ph
45._crit_edge:
46  ret void
47}
48