xref: /aosp_15_r20/external/llvm/test/CodeGen/AArch64/arm64-stp-aa.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=arm64 -enable-misched=false -aarch64-stp-suppress=false -verify-machineinstrs | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; The next set of tests makes sure we can combine the second instruction into
4*9880d681SAndroid Build Coastguard Worker; the first.
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: stp_int_aa
7*9880d681SAndroid Build Coastguard Worker; CHECK: stp w0, w1, [x2]
8*9880d681SAndroid Build Coastguard Worker; CHECK: ldr w0, [x2, #8]
9*9880d681SAndroid Build Coastguard Worker; CHECK: ret
10*9880d681SAndroid Build Coastguard Workerdefine i32 @stp_int_aa(i32 %a, i32 %b, i32* nocapture %p) nounwind {
11*9880d681SAndroid Build Coastguard Worker  store i32 %a, i32* %p, align 4
12*9880d681SAndroid Build Coastguard Worker  %ld.ptr = getelementptr inbounds i32, i32* %p, i64 2
13*9880d681SAndroid Build Coastguard Worker  %tmp = load i32, i32* %ld.ptr, align 4
14*9880d681SAndroid Build Coastguard Worker  %add.ptr = getelementptr inbounds i32, i32* %p, i64 1
15*9880d681SAndroid Build Coastguard Worker  store i32 %b, i32* %add.ptr, align 4
16*9880d681SAndroid Build Coastguard Worker  ret i32 %tmp
17*9880d681SAndroid Build Coastguard Worker}
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: stp_long_aa
20*9880d681SAndroid Build Coastguard Worker; CHECK: stp x0, x1, [x2]
21*9880d681SAndroid Build Coastguard Worker; CHECK: ldr x0, [x2, #16]
22*9880d681SAndroid Build Coastguard Worker; CHECK: ret
23*9880d681SAndroid Build Coastguard Workerdefine i64 @stp_long_aa(i64 %a, i64 %b, i64* nocapture %p) nounwind {
24*9880d681SAndroid Build Coastguard Worker  store i64 %a, i64* %p, align 8
25*9880d681SAndroid Build Coastguard Worker  %ld.ptr = getelementptr inbounds i64, i64* %p, i64 2
26*9880d681SAndroid Build Coastguard Worker  %tmp = load i64, i64* %ld.ptr, align 4
27*9880d681SAndroid Build Coastguard Worker  %add.ptr = getelementptr inbounds i64, i64* %p, i64 1
28*9880d681SAndroid Build Coastguard Worker  store i64 %b, i64* %add.ptr, align 8
29*9880d681SAndroid Build Coastguard Worker  ret i64 %tmp
30*9880d681SAndroid Build Coastguard Worker}
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: stp_float_aa
33*9880d681SAndroid Build Coastguard Worker; CHECK: stp s0, s1, [x0]
34*9880d681SAndroid Build Coastguard Worker; CHECK: ldr s0, [x0, #8]
35*9880d681SAndroid Build Coastguard Worker; CHECK: ret
36*9880d681SAndroid Build Coastguard Workerdefine float @stp_float_aa(float %a, float %b, float* nocapture %p) nounwind {
37*9880d681SAndroid Build Coastguard Worker  store float %a, float* %p, align 4
38*9880d681SAndroid Build Coastguard Worker  %ld.ptr = getelementptr inbounds float, float* %p, i64 2
39*9880d681SAndroid Build Coastguard Worker  %tmp = load float, float* %ld.ptr, align 4
40*9880d681SAndroid Build Coastguard Worker  %add.ptr = getelementptr inbounds float, float* %p, i64 1
41*9880d681SAndroid Build Coastguard Worker  store float %b, float* %add.ptr, align 4
42*9880d681SAndroid Build Coastguard Worker  ret float %tmp
43*9880d681SAndroid Build Coastguard Worker}
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: stp_double_aa
46*9880d681SAndroid Build Coastguard Worker; CHECK: stp d0, d1, [x0]
47*9880d681SAndroid Build Coastguard Worker; CHECK: ldr d0, [x0, #16]
48*9880d681SAndroid Build Coastguard Worker; CHECK: ret
49*9880d681SAndroid Build Coastguard Workerdefine double @stp_double_aa(double %a, double %b, double* nocapture %p) nounwind {
50*9880d681SAndroid Build Coastguard Worker  store double %a, double* %p, align 8
51*9880d681SAndroid Build Coastguard Worker  %ld.ptr = getelementptr inbounds double, double* %p, i64 2
52*9880d681SAndroid Build Coastguard Worker  %tmp = load double, double* %ld.ptr, align 4
53*9880d681SAndroid Build Coastguard Worker  %add.ptr = getelementptr inbounds double, double* %p, i64 1
54*9880d681SAndroid Build Coastguard Worker  store double %b, double* %add.ptr, align 8
55*9880d681SAndroid Build Coastguard Worker  ret double %tmp
56*9880d681SAndroid Build Coastguard Worker}
57*9880d681SAndroid Build Coastguard Worker
58*9880d681SAndroid Build Coastguard Worker; The next set of tests makes sure we can combine the first instruction into
59*9880d681SAndroid Build Coastguard Worker; the second.
60*9880d681SAndroid Build Coastguard Worker
61*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: stp_int_aa_after
62*9880d681SAndroid Build Coastguard Worker; CHECK: ldr w0, [x3, #4]
63*9880d681SAndroid Build Coastguard Worker; CHECK: stp w1, w2, [x3]
64*9880d681SAndroid Build Coastguard Worker; CHECK: ret
65*9880d681SAndroid Build Coastguard Workerdefine i32 @stp_int_aa_after(i32 %w0, i32 %a, i32 %b, i32* nocapture %p) nounwind {
66*9880d681SAndroid Build Coastguard Worker  store i32 %a, i32* %p, align 4
67*9880d681SAndroid Build Coastguard Worker  %ld.ptr = getelementptr inbounds i32, i32* %p, i64 1
68*9880d681SAndroid Build Coastguard Worker  %tmp = load i32, i32* %ld.ptr, align 4
69*9880d681SAndroid Build Coastguard Worker  %add.ptr = getelementptr inbounds i32, i32* %p, i64 1
70*9880d681SAndroid Build Coastguard Worker  store i32 %b, i32* %add.ptr, align 4
71*9880d681SAndroid Build Coastguard Worker  ret i32 %tmp
72*9880d681SAndroid Build Coastguard Worker}
73*9880d681SAndroid Build Coastguard Worker
74*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: stp_long_aa_after
75*9880d681SAndroid Build Coastguard Worker; CHECK: ldr x0, [x3, #8]
76*9880d681SAndroid Build Coastguard Worker; CHECK: stp x1, x2, [x3]
77*9880d681SAndroid Build Coastguard Worker; CHECK: ret
78*9880d681SAndroid Build Coastguard Workerdefine i64 @stp_long_aa_after(i64 %x0, i64 %a, i64 %b, i64* nocapture %p) nounwind {
79*9880d681SAndroid Build Coastguard Worker  store i64 %a, i64* %p, align 8
80*9880d681SAndroid Build Coastguard Worker  %ld.ptr = getelementptr inbounds i64, i64* %p, i64 1
81*9880d681SAndroid Build Coastguard Worker  %tmp = load i64, i64* %ld.ptr, align 4
82*9880d681SAndroid Build Coastguard Worker  %add.ptr = getelementptr inbounds i64, i64* %p, i64 1
83*9880d681SAndroid Build Coastguard Worker  store i64 %b, i64* %add.ptr, align 8
84*9880d681SAndroid Build Coastguard Worker  ret i64 %tmp
85*9880d681SAndroid Build Coastguard Worker}
86*9880d681SAndroid Build Coastguard Worker
87*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: stp_float_aa_after
88*9880d681SAndroid Build Coastguard Worker; CHECK: ldr s0, [x0, #4]
89*9880d681SAndroid Build Coastguard Worker; CHECK: stp s1, s2, [x0]
90*9880d681SAndroid Build Coastguard Worker; CHECK: ret
91*9880d681SAndroid Build Coastguard Workerdefine float @stp_float_aa_after(float %s0, float %a, float %b, float* nocapture %p) nounwind {
92*9880d681SAndroid Build Coastguard Worker  store float %a, float* %p, align 4
93*9880d681SAndroid Build Coastguard Worker  %ld.ptr = getelementptr inbounds float, float* %p, i64 1
94*9880d681SAndroid Build Coastguard Worker  %tmp = load float, float* %ld.ptr, align 4
95*9880d681SAndroid Build Coastguard Worker  %add.ptr = getelementptr inbounds float, float* %p, i64 1
96*9880d681SAndroid Build Coastguard Worker  store float %b, float* %add.ptr, align 4
97*9880d681SAndroid Build Coastguard Worker  ret float %tmp
98*9880d681SAndroid Build Coastguard Worker}
99*9880d681SAndroid Build Coastguard Worker
100*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: stp_double_aa_after
101*9880d681SAndroid Build Coastguard Worker; CHECK: ldr d0, [x0, #8]
102*9880d681SAndroid Build Coastguard Worker; CHECK: stp d1, d2, [x0]
103*9880d681SAndroid Build Coastguard Worker; CHECK: ret
104*9880d681SAndroid Build Coastguard Workerdefine double @stp_double_aa_after(double %d0, double %a, double %b, double* nocapture %p) nounwind {
105*9880d681SAndroid Build Coastguard Worker  store double %a, double* %p, align 8
106*9880d681SAndroid Build Coastguard Worker  %ld.ptr = getelementptr inbounds double, double* %p, i64 1
107*9880d681SAndroid Build Coastguard Worker  %tmp = load double, double* %ld.ptr, align 4
108*9880d681SAndroid Build Coastguard Worker  %add.ptr = getelementptr inbounds double, double* %p, i64 1
109*9880d681SAndroid Build Coastguard Worker  store double %b, double* %add.ptr, align 8
110*9880d681SAndroid Build Coastguard Worker  ret double %tmp
111*9880d681SAndroid Build Coastguard Worker}
112*9880d681SAndroid Build Coastguard Worker
113*9880d681SAndroid Build Coastguard Worker; Check that the stores %c and %d are paired after the fadd instruction,
114*9880d681SAndroid Build Coastguard Worker; and then the stores %a and %d are paired after proving that they do not
115*9880d681SAndroid Build Coastguard Worker; depend on the the (%c, %d) pair.
116*9880d681SAndroid Build Coastguard Worker;
117*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: st1:
118*9880d681SAndroid Build Coastguard Worker; CHECK: stp q0, q1, [x{{[0-9]+}}]
119*9880d681SAndroid Build Coastguard Worker; CHECK: fadd
120*9880d681SAndroid Build Coastguard Worker; CHECK: stp q2, q0, [x{{[0-9]+}}, #32]
121*9880d681SAndroid Build Coastguard Workerdefine void @st1(<4 x float> %a, <4 x float> %b, <4 x float> %c, <4 x float> %d, float* %base, i64 %index) {
122*9880d681SAndroid Build Coastguard Workerentry:
123*9880d681SAndroid Build Coastguard Worker  %a0 = getelementptr inbounds float, float* %base, i64 %index
124*9880d681SAndroid Build Coastguard Worker  %b0 = getelementptr float, float* %a0, i64 4
125*9880d681SAndroid Build Coastguard Worker  %c0 = getelementptr float, float* %a0, i64 8
126*9880d681SAndroid Build Coastguard Worker  %d0 = getelementptr float, float* %a0, i64 12
127*9880d681SAndroid Build Coastguard Worker
128*9880d681SAndroid Build Coastguard Worker  %a1 = bitcast float* %a0 to <4 x float>*
129*9880d681SAndroid Build Coastguard Worker  %b1 = bitcast float* %b0 to <4 x float>*
130*9880d681SAndroid Build Coastguard Worker  %c1 = bitcast float* %c0 to <4 x float>*
131*9880d681SAndroid Build Coastguard Worker  %d1 = bitcast float* %d0 to <4 x float>*
132*9880d681SAndroid Build Coastguard Worker
133*9880d681SAndroid Build Coastguard Worker  store <4 x float> %c, <4 x float> * %c1, align 4
134*9880d681SAndroid Build Coastguard Worker  store <4 x float> %a, <4 x float> * %a1, align 4
135*9880d681SAndroid Build Coastguard Worker
136*9880d681SAndroid Build Coastguard Worker  ; This fadd forces the compiler to pair %c and %e after fadd, and leave the
137*9880d681SAndroid Build Coastguard Worker  ; stores %a and %b separated by a stp. The dependence analysis needs then to
138*9880d681SAndroid Build Coastguard Worker  ; prove that it is safe to move %b past the stp to be paired with %a.
139*9880d681SAndroid Build Coastguard Worker  %e = fadd fast <4 x float> %d, %a
140*9880d681SAndroid Build Coastguard Worker
141*9880d681SAndroid Build Coastguard Worker  store <4 x float> %e, <4 x float>* %d1, align 4
142*9880d681SAndroid Build Coastguard Worker  store <4 x float> %b, <4 x float>* %b1, align 4
143*9880d681SAndroid Build Coastguard Worker
144*9880d681SAndroid Build Coastguard Worker  ret void
145*9880d681SAndroid Build Coastguard Worker}
146