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, %struct.A* 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 %struct.A* [ %addr, %.lr.ph ], [ %p, %0 ]
20  %a2 = getelementptr inbounds %struct.A, %struct.A* %.01, i64 0, i32 0
21  store i8 1, i8* %a2, align 1
22  %a3 = getelementptr inbounds %struct.A, %struct.A* %.01, i64 0, i32 1
23  store i8 2, i8* %a3, align 1
24  %a4 = getelementptr inbounds %struct.A, %struct.A* %.01, i64 0, i32 2
25  store i8 3, i8* %a4, align 1
26  %a5 = getelementptr inbounds %struct.A, %struct.A* %.01, i64 0, i32 3
27  store i8 4, i8* %a5, align 1
28  %a6 = getelementptr inbounds %struct.A, %struct.A* %.01, i64 0, i32 4
29  store i8 5, i8* %a6, align 1
30  %a7 = getelementptr inbounds %struct.A, %struct.A* %.01, i64 0, i32 5
31  store i8 6, i8* %a7, align 1
32  %a8 = getelementptr inbounds %struct.A, %struct.A* %.01, i64 0, i32 6
33  store i8 7, i8* %a8, align 1
34  %a9 = getelementptr inbounds %struct.A, %struct.A* %.01, i64 0, i32 7
35  store i8 8, i8* %a9, align 1
36
37  ;
38  %addr_last = getelementptr inbounds %struct.A, %struct.A* %.01, i64 0, i32 8
39  store i32 0, i32* %addr_last, align 4
40
41
42  %add = add nsw i32 %i.02, 1
43  %addr = getelementptr inbounds %struct.A, %struct.A* %.01, i64 1
44  %exitcond = icmp eq i32 %add, %count
45  br i1 %exitcond, label %._crit_edge, label %.lr.ph
46._crit_edge:
47  ret void
48}
49