1 ; RUN: llc < %s -mtriple=arm64-eabi -aarch64-enable-stp-suppress=false -verify-machineinstrs -mcpu=cyclone | FileCheck %s
4 ; CHECK: stp w0, w1, [x2]
5 define void @stp_int(i32 %a, i32 %b, ptr nocapture %p) nounwind {
6 store i32 %a, ptr %p, align 4
7 %add.ptr = getelementptr inbounds i32, ptr %p, i64 1
8 store i32 %b, ptr %add.ptr, align 4
12 ; CHECK-LABEL: stp_long
13 ; CHECK: stp x0, x1, [x2]
14 define void @stp_long(i64 %a, i64 %b, ptr nocapture %p) nounwind {
15 store i64 %a, ptr %p, align 8
16 %add.ptr = getelementptr inbounds i64, ptr %p, i64 1
17 store i64 %b, ptr %add.ptr, align 8
21 ; CHECK-LABEL: stp_float
22 ; CHECK: stp s0, s1, [x0]
23 define void @stp_float(float %a, float %b, ptr nocapture %p) nounwind {
24 store float %a, ptr %p, align 4
25 %add.ptr = getelementptr inbounds float, ptr %p, i64 1
26 store float %b, ptr %add.ptr, align 4
30 ; CHECK-LABEL: stp_double
31 ; CHECK: stp d0, d1, [x0]
32 define void @stp_double(double %a, double %b, ptr nocapture %p) nounwind {
33 store double %a, ptr %p, align 8
34 %add.ptr = getelementptr inbounds double, ptr %p, i64 1
35 store double %b, ptr %add.ptr, align 8
39 ; CHECK-LABEL: stp_doublex2
40 ; CHECK: stp q0, q1, [x0]
41 define void @stp_doublex2(<2 x double> %a, <2 x double> %b, ptr nocapture %p) nounwind {
42 store <2 x double> %a, ptr %p, align 16
43 %add.ptr = getelementptr inbounds <2 x double>, ptr %p, i64 1
44 store <2 x double> %b, ptr %add.ptr, align 16
48 ; Test the load/store optimizer---combine ldurs into a ldp, if appropriate
49 define void @stur_int(i32 %a, i32 %b, ptr nocapture %p) nounwind {
50 ; CHECK-LABEL: stur_int
51 ; CHECK: stp w{{[0-9]+}}, {{w[0-9]+}}, [x{{[0-9]+}}, #-8]
53 %p1 = getelementptr inbounds i32, ptr %p, i32 -1
54 store i32 %a, ptr %p1, align 2
55 %p2 = getelementptr inbounds i32, ptr %p, i32 -2
56 store i32 %b, ptr %p2, align 2
60 define void @stur_long(i64 %a, i64 %b, ptr nocapture %p) nounwind {
61 ; CHECK-LABEL: stur_long
62 ; CHECK: stp x{{[0-9]+}}, {{x[0-9]+}}, [x{{[0-9]+}}, #-16]
64 %p1 = getelementptr inbounds i64, ptr %p, i32 -1
65 store i64 %a, ptr %p1, align 2
66 %p2 = getelementptr inbounds i64, ptr %p, i32 -2
67 store i64 %b, ptr %p2, align 2
71 define void @stur_float(float %a, float %b, ptr nocapture %p) nounwind {
72 ; CHECK-LABEL: stur_float
73 ; CHECK: stp s{{[0-9]+}}, {{s[0-9]+}}, [x{{[0-9]+}}, #-8]
75 %p1 = getelementptr inbounds float, ptr %p, i32 -1
76 store float %a, ptr %p1, align 2
77 %p2 = getelementptr inbounds float, ptr %p, i32 -2
78 store float %b, ptr %p2, align 2
82 define void @stur_double(double %a, double %b, ptr nocapture %p) nounwind {
83 ; CHECK-LABEL: stur_double
84 ; CHECK: stp d{{[0-9]+}}, {{d[0-9]+}}, [x{{[0-9]+}}, #-16]
86 %p1 = getelementptr inbounds double, ptr %p, i32 -1
87 store double %a, ptr %p1, align 2
88 %p2 = getelementptr inbounds double, ptr %p, i32 -2
89 store double %b, ptr %p2, align 2
93 define void @stur_doublex2(<2 x double> %a, <2 x double> %b, ptr nocapture %p) nounwind {
94 ; CHECK-LABEL: stur_doublex2
95 ; CHECK: stp q{{[0-9]+}}, q{{[0-9]+}}, [x{{[0-9]+}}, #-32]
97 %p1 = getelementptr inbounds <2 x double>, ptr %p, i32 -1
98 store <2 x double> %a, ptr %p1, align 2
99 %p2 = getelementptr inbounds <2 x double>, ptr %p, i32 -2
100 store <2 x double> %b, ptr %p2, align 2
104 define void @splat_v4i32(i32 %v, ptr %p) {
107 ; CHECK-LABEL: splat_v4i32
108 ; CHECK-DAG: dup v0.4s, w0
109 ; CHECK-DAG: str q0, [x1]
112 %p17 = insertelement <4 x i32> undef, i32 %v, i32 0
113 %p18 = insertelement <4 x i32> %p17, i32 %v, i32 1
114 %p19 = insertelement <4 x i32> %p18, i32 %v, i32 2
115 %p20 = insertelement <4 x i32> %p19, i32 %v, i32 3
116 store <4 x i32> %p20, ptr %p, align 4
120 ; Check that a non-splat store that is storing a vector created by 4
121 ; insertelements that is not a splat vector does not get split.
122 define void @nosplat_v4i32(i32 %v, ptr %p) {
125 ; CHECK-LABEL: nosplat_v4i32:
127 ; CHECK: ldr q[[REG1:[0-9]+]],
128 ; CHECK-DAG: mov v[[REG1]].s[1], w0
129 ; CHECK-DAG: mov v[[REG1]].s[2], w0
130 ; CHECK-DAG: mov v[[REG1]].s[3], w0
131 ; CHECK: str q[[REG1]], [x1]
134 %p17 = insertelement <4 x i32> undef, i32 %v, i32 %v
135 %p18 = insertelement <4 x i32> %p17, i32 %v, i32 1
136 %p19 = insertelement <4 x i32> %p18, i32 %v, i32 2
137 %p20 = insertelement <4 x i32> %p19, i32 %v, i32 3
138 store <4 x i32> %p20, ptr %p, align 4
142 ; Check that a non-splat store that is storing a vector created by 4
143 ; insertelements that is not a splat vector does not get split.
144 define void @nosplat2_v4i32(i32 %v, ptr %p, <4 x i32> %vin) {
147 ; CHECK-LABEL: nosplat2_v4i32:
148 ; CHECK: mov v[[REG1]].s[1], w0
149 ; CHECK-DAG: mov v[[REG1]].s[2], w0
150 ; CHECK-DAG: mov v[[REG1]].s[3], w0
151 ; CHECK: str q[[REG1]], [x1]
154 %p18 = insertelement <4 x i32> %vin, i32 %v, i32 1
155 %p19 = insertelement <4 x i32> %p18, i32 %v, i32 2
156 %p20 = insertelement <4 x i32> %p19, i32 %v, i32 3
157 store <4 x i32> %p20, ptr %p, align 4
161 ; Read of %b to compute %tmp2 shouldn't prevent formation of stp
162 ; CHECK-LABEL: stp_int_rar_hazard
163 ; CHECK: ldr [[REG:w[0-9]+]], [x2, #8]
164 ; CHECK: add w8, [[REG]], w1
165 ; CHECK: stp w0, w1, [x2]
167 define i32 @stp_int_rar_hazard(i32 %a, i32 %b, ptr nocapture %p) nounwind {
168 store i32 %a, ptr %p, align 4
169 %ld.ptr = getelementptr inbounds i32, ptr %p, i64 2
170 %tmp = load i32, ptr %ld.ptr, align 4
171 %tmp2 = add i32 %tmp, %b
172 %add.ptr = getelementptr inbounds i32, ptr %p, i64 1
173 store i32 %b, ptr %add.ptr, align 4
177 ; Read of %b to compute %tmp2 shouldn't prevent formation of stp
178 ; CHECK-LABEL: stp_int_rar_hazard_after
179 ; CHECK: ldr [[REG:w[0-9]+]], [x3, #4]
180 ; CHECK: add w0, [[REG]], w2
181 ; CHECK: stp w1, w2, [x3]
183 define i32 @stp_int_rar_hazard_after(i32 %w0, i32 %a, i32 %b, ptr nocapture %p) nounwind {
184 store i32 %a, ptr %p, align 4
185 %ld.ptr = getelementptr inbounds i32, ptr %p, i64 1
186 %tmp = load i32, ptr %ld.ptr, align 4
187 %tmp2 = add i32 %tmp, %b
188 %add.ptr = getelementptr inbounds i32, ptr %p, i64 1
189 store i32 %b, ptr %add.ptr, align 4