xref: /aosp_15_r20/external/llvm/test/CodeGen/AArch64/arm64-stur.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=arm64 -aarch64-neon-syntax=apple -mcpu=cyclone | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker%struct.X = type <{ i32, i64, i64 }>
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Workerdefine void @foo1(i32* %p, i64 %val) nounwind {
5*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: foo1:
6*9880d681SAndroid Build Coastguard Worker; CHECK: 	stur	w1, [x0, #-4]
7*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: 	ret
8*9880d681SAndroid Build Coastguard Worker  %tmp1 = trunc i64 %val to i32
9*9880d681SAndroid Build Coastguard Worker  %ptr = getelementptr inbounds i32, i32* %p, i64 -1
10*9880d681SAndroid Build Coastguard Worker  store i32 %tmp1, i32* %ptr, align 4
11*9880d681SAndroid Build Coastguard Worker  ret void
12*9880d681SAndroid Build Coastguard Worker}
13*9880d681SAndroid Build Coastguard Workerdefine void @foo2(i16* %p, i64 %val) nounwind {
14*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: foo2:
15*9880d681SAndroid Build Coastguard Worker; CHECK: 	sturh	w1, [x0, #-2]
16*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: 	ret
17*9880d681SAndroid Build Coastguard Worker  %tmp1 = trunc i64 %val to i16
18*9880d681SAndroid Build Coastguard Worker  %ptr = getelementptr inbounds i16, i16* %p, i64 -1
19*9880d681SAndroid Build Coastguard Worker  store i16 %tmp1, i16* %ptr, align 2
20*9880d681SAndroid Build Coastguard Worker  ret void
21*9880d681SAndroid Build Coastguard Worker}
22*9880d681SAndroid Build Coastguard Workerdefine void @foo3(i8* %p, i64 %val) nounwind {
23*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: foo3:
24*9880d681SAndroid Build Coastguard Worker; CHECK: 	sturb	w1, [x0, #-1]
25*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: 	ret
26*9880d681SAndroid Build Coastguard Worker  %tmp1 = trunc i64 %val to i8
27*9880d681SAndroid Build Coastguard Worker  %ptr = getelementptr inbounds i8, i8* %p, i64 -1
28*9880d681SAndroid Build Coastguard Worker  store i8 %tmp1, i8* %ptr, align 1
29*9880d681SAndroid Build Coastguard Worker  ret void
30*9880d681SAndroid Build Coastguard Worker}
31*9880d681SAndroid Build Coastguard Workerdefine void @foo4(i16* %p, i32 %val) nounwind {
32*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: foo4:
33*9880d681SAndroid Build Coastguard Worker; CHECK: 	sturh	w1, [x0, #-2]
34*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: 	ret
35*9880d681SAndroid Build Coastguard Worker  %tmp1 = trunc i32 %val to i16
36*9880d681SAndroid Build Coastguard Worker  %ptr = getelementptr inbounds i16, i16* %p, i32 -1
37*9880d681SAndroid Build Coastguard Worker  store i16 %tmp1, i16* %ptr, align 2
38*9880d681SAndroid Build Coastguard Worker  ret void
39*9880d681SAndroid Build Coastguard Worker}
40*9880d681SAndroid Build Coastguard Workerdefine void @foo5(i8* %p, i32 %val) nounwind {
41*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: foo5:
42*9880d681SAndroid Build Coastguard Worker; CHECK: 	sturb	w1, [x0, #-1]
43*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: 	ret
44*9880d681SAndroid Build Coastguard Worker  %tmp1 = trunc i32 %val to i8
45*9880d681SAndroid Build Coastguard Worker  %ptr = getelementptr inbounds i8, i8* %p, i32 -1
46*9880d681SAndroid Build Coastguard Worker  store i8 %tmp1, i8* %ptr, align 1
47*9880d681SAndroid Build Coastguard Worker  ret void
48*9880d681SAndroid Build Coastguard Worker}
49*9880d681SAndroid Build Coastguard Worker
50*9880d681SAndroid Build Coastguard Workerdefine void @foo(%struct.X* nocapture %p) nounwind optsize ssp {
51*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: foo:
52*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: str
53*9880d681SAndroid Build Coastguard Worker; CHECK: stur    xzr, [x0, #12]
54*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: stur    xzr, [x0, #4]
55*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: ret
56*9880d681SAndroid Build Coastguard Worker  %B = getelementptr inbounds %struct.X, %struct.X* %p, i64 0, i32 1
57*9880d681SAndroid Build Coastguard Worker  %val = bitcast i64* %B to i8*
58*9880d681SAndroid Build Coastguard Worker  call void @llvm.memset.p0i8.i64(i8* %val, i8 0, i64 16, i32 1, i1 false)
59*9880d681SAndroid Build Coastguard Worker  ret void
60*9880d681SAndroid Build Coastguard Worker}
61*9880d681SAndroid Build Coastguard Worker
62*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind
63*9880d681SAndroid Build Coastguard Worker
64*9880d681SAndroid Build Coastguard Worker; Unaligned 16b stores are split into 8b stores for performance.
65*9880d681SAndroid Build Coastguard Worker; radar://15424193
66*9880d681SAndroid Build Coastguard Worker
67*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: unaligned:
68*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: str q0
69*9880d681SAndroid Build Coastguard Worker; CHECK: str     d[[REG:[0-9]+]], [x0]
70*9880d681SAndroid Build Coastguard Worker; CHECK: ext.16b v[[REG2:[0-9]+]], v[[REG]], v[[REG]], #8
71*9880d681SAndroid Build Coastguard Worker; CHECK: str     d[[REG2]], [x0, #8]
72*9880d681SAndroid Build Coastguard Workerdefine void @unaligned(<4 x i32>* %p, <4 x i32> %v) nounwind {
73*9880d681SAndroid Build Coastguard Worker  store <4 x i32> %v, <4 x i32>* %p, align 4
74*9880d681SAndroid Build Coastguard Worker  ret void
75*9880d681SAndroid Build Coastguard Worker}
76*9880d681SAndroid Build Coastguard Worker
77*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: aligned:
78*9880d681SAndroid Build Coastguard Worker; CHECK: str q0
79*9880d681SAndroid Build Coastguard Workerdefine void @aligned(<4 x i32>* %p, <4 x i32> %v) nounwind {
80*9880d681SAndroid Build Coastguard Worker  store <4 x i32> %v, <4 x i32>* %p
81*9880d681SAndroid Build Coastguard Worker  ret void
82*9880d681SAndroid Build Coastguard Worker}
83*9880d681SAndroid Build Coastguard Worker
84*9880d681SAndroid Build Coastguard Worker; Don't split one and two byte aligned stores.
85*9880d681SAndroid Build Coastguard Worker; radar://16349308
86*9880d681SAndroid Build Coastguard Worker
87*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: twobytealign:
88*9880d681SAndroid Build Coastguard Worker; CHECK: str q0
89*9880d681SAndroid Build Coastguard Workerdefine void @twobytealign(<4 x i32>* %p, <4 x i32> %v) nounwind {
90*9880d681SAndroid Build Coastguard Worker  store <4 x i32> %v, <4 x i32>* %p, align 2
91*9880d681SAndroid Build Coastguard Worker  ret void
92*9880d681SAndroid Build Coastguard Worker}
93*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: onebytealign:
94*9880d681SAndroid Build Coastguard Worker; CHECK: str q0
95*9880d681SAndroid Build Coastguard Workerdefine void @onebytealign(<4 x i32>* %p, <4 x i32> %v) nounwind {
96*9880d681SAndroid Build Coastguard Worker  store <4 x i32> %v, <4 x i32>* %p, align 1
97*9880d681SAndroid Build Coastguard Worker  ret void
98*9880d681SAndroid Build Coastguard Worker}
99