xref: /aosp_15_r20/external/llvm/test/CodeGen/ARM/fast-isel-align.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=armv7-apple-ios -verify-machineinstrs | FileCheck %s --check-prefix=ARM
2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-ios -verify-machineinstrs | FileCheck %s --check-prefix=THUMB
3*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -mattr=+strict-align -relocation-model=dynamic-no-pic -mtriple=armv7-apple-ios -verify-machineinstrs | FileCheck %s --check-prefix=ARM-STRICT-ALIGN
4*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -mattr=+strict-align -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-ios -verify-machineinstrs | FileCheck %s --check-prefix=THUMB-STRICT-ALIGN
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=armv7-linux-gnueabi -verify-machineinstrs | FileCheck %s --check-prefix=ARM
7*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=thumbv7-linux-gnueabi -verify-machineinstrs | FileCheck %s --check-prefix=THUMB
8*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -mattr=+strict-align -relocation-model=dynamic-no-pic -mtriple=armv7-linux-gnueabi -verify-machineinstrs | FileCheck %s --check-prefix=ARM-STRICT-ALIGN
9*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -mattr=+strict-align -relocation-model=dynamic-no-pic -mtriple=thumbv7-linux-gnueabi -verify-machineinstrs | FileCheck %s --check-prefix=THUMB-STRICT-ALIGN
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=armv7-unknown-nacl -verify-machineinstrs | FileCheck %s --check-prefix=ARM
12*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -mattr=+strict-align -relocation-model=dynamic-no-pic -mtriple=armv7-unknown-nacl -verify-machineinstrs | FileCheck %s --check-prefix=ARM-STRICT-ALIGN
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -mattr=+strict-align -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=armv7-unknown-unknown -verify-machineinstrs | FileCheck %s --check-prefix=ARM-STRICT-ALIGN
15*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0  -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=thumbv7-unknown-unknown -mattr=+strict-align -verify-machineinstrs | FileCheck %s --check-prefix=THUMB-STRICT-ALIGN
16*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=armv7-unknown-unknown -verify-machineinstrs | FileCheck %s --check-prefix=ARM
17*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=thumbv7-unknown-unknown -verify-machineinstrs | FileCheck %s --check-prefix=THUMB
18*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -relocation-model=dynamic-no-pic -mtriple=armv7-unknown-unknown -mattr=+strict-align -verify-machineinstrs | FileCheck %s --check-prefix=ARM-STRICT-ALIGN
19*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -O0 -relocation-model=dynamic-no-pic -mtriple=thumbv7-unknown-unknown -mattr=+strict-align -verify-machineinstrs | FileCheck %s --check-prefix=THUMB-STRICT-ALIGN
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Worker; Check unaligned stores
22*9880d681SAndroid Build Coastguard Worker%struct.anon = type <{ float }>
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Worker@a = common global %struct.anon* null, align 4
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Workerdefine void @unaligned_store(float %x, float %y) nounwind {
27*9880d681SAndroid Build Coastguard Workerentry:
28*9880d681SAndroid Build Coastguard Worker; ARM: @unaligned_store
29*9880d681SAndroid Build Coastguard Worker; ARM: vmov r1, s0
30*9880d681SAndroid Build Coastguard Worker; ARM: str r1, [r0]
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Worker; THUMB: @unaligned_store
33*9880d681SAndroid Build Coastguard Worker; THUMB: vmov r1, s0
34*9880d681SAndroid Build Coastguard Worker; THUMB: str r1, [r0]
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Worker  %add = fadd float %x, %y
37*9880d681SAndroid Build Coastguard Worker  %0 = load %struct.anon*, %struct.anon** @a, align 4
38*9880d681SAndroid Build Coastguard Worker  %x1 = getelementptr inbounds %struct.anon, %struct.anon* %0, i32 0, i32 0
39*9880d681SAndroid Build Coastguard Worker  store float %add, float* %x1, align 1
40*9880d681SAndroid Build Coastguard Worker  ret void
41*9880d681SAndroid Build Coastguard Worker}
42*9880d681SAndroid Build Coastguard Worker
43*9880d681SAndroid Build Coastguard Worker; Doublewords require only word-alignment.
44*9880d681SAndroid Build Coastguard Worker; rdar://10528060
45*9880d681SAndroid Build Coastguard Worker%struct.anon.0 = type { double }
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Worker@foo_unpacked = common global %struct.anon.0 zeroinitializer, align 4
48*9880d681SAndroid Build Coastguard Worker
49*9880d681SAndroid Build Coastguard Workerdefine void @word_aligned_f64_store(double %a, double %b) nounwind {
50*9880d681SAndroid Build Coastguard Workerentry:
51*9880d681SAndroid Build Coastguard Worker; ARM: @word_aligned_f64_store
52*9880d681SAndroid Build Coastguard Worker; THUMB: @word_aligned_f64_store
53*9880d681SAndroid Build Coastguard Worker  %add = fadd double %a, %b
54*9880d681SAndroid Build Coastguard Worker  store double %add, double* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @foo_unpacked, i32 0, i32 0), align 4
55*9880d681SAndroid Build Coastguard Worker; ARM: vstr d16, [r0]
56*9880d681SAndroid Build Coastguard Worker; THUMB: vstr d16, [r0]
57*9880d681SAndroid Build Coastguard Worker  ret void
58*9880d681SAndroid Build Coastguard Worker}
59*9880d681SAndroid Build Coastguard Worker
60*9880d681SAndroid Build Coastguard Worker; Check unaligned loads of floats
61*9880d681SAndroid Build Coastguard Worker%class.TAlignTest = type <{ i16, float }>
62*9880d681SAndroid Build Coastguard Worker
63*9880d681SAndroid Build Coastguard Workerdefine zeroext i1 @unaligned_f32_load(%class.TAlignTest* %this) nounwind align 2 {
64*9880d681SAndroid Build Coastguard Workerentry:
65*9880d681SAndroid Build Coastguard Worker; ARM: @unaligned_f32_load
66*9880d681SAndroid Build Coastguard Worker; THUMB: @unaligned_f32_load
67*9880d681SAndroid Build Coastguard Worker  %0 = alloca %class.TAlignTest*, align 4
68*9880d681SAndroid Build Coastguard Worker  store %class.TAlignTest* %this, %class.TAlignTest** %0, align 4
69*9880d681SAndroid Build Coastguard Worker  %1 = load %class.TAlignTest*, %class.TAlignTest** %0
70*9880d681SAndroid Build Coastguard Worker  %2 = getelementptr inbounds %class.TAlignTest, %class.TAlignTest* %1, i32 0, i32 1
71*9880d681SAndroid Build Coastguard Worker  %3 = load float, float* %2, align 1
72*9880d681SAndroid Build Coastguard Worker  %4 = fcmp une float %3, 0.000000e+00
73*9880d681SAndroid Build Coastguard Worker; ARM: ldr r[[R:[0-9]+]], [r0, #2]
74*9880d681SAndroid Build Coastguard Worker; ARM: vmov s0, r[[R]]
75*9880d681SAndroid Build Coastguard Worker; ARM: vcmpe.f32 s0, #0
76*9880d681SAndroid Build Coastguard Worker; THUMB: ldr.w r[[R:[0-9]+]], [r0, #2]
77*9880d681SAndroid Build Coastguard Worker; THUMB: vmov s0, r[[R]]
78*9880d681SAndroid Build Coastguard Worker; THUMB: vcmpe.f32 s0, #0
79*9880d681SAndroid Build Coastguard Worker  ret i1 %4
80*9880d681SAndroid Build Coastguard Worker}
81*9880d681SAndroid Build Coastguard Worker
82*9880d681SAndroid Build Coastguard Workerdefine void @unaligned_i16_store(i16 %x, i16* %y) nounwind {
83*9880d681SAndroid Build Coastguard Workerentry:
84*9880d681SAndroid Build Coastguard Worker; ARM-STRICT-ALIGN: @unaligned_i16_store
85*9880d681SAndroid Build Coastguard Worker; ARM-STRICT-ALIGN: strb
86*9880d681SAndroid Build Coastguard Worker; ARM-STRICT-ALIGN: strb
87*9880d681SAndroid Build Coastguard Worker
88*9880d681SAndroid Build Coastguard Worker; THUMB-STRICT-ALIGN: @unaligned_i16_store
89*9880d681SAndroid Build Coastguard Worker; THUMB-STRICT-ALIGN: strb
90*9880d681SAndroid Build Coastguard Worker; THUMB-STRICT-ALIGN: strb
91*9880d681SAndroid Build Coastguard Worker
92*9880d681SAndroid Build Coastguard Worker  store i16 %x, i16* %y, align 1
93*9880d681SAndroid Build Coastguard Worker  ret void
94*9880d681SAndroid Build Coastguard Worker}
95*9880d681SAndroid Build Coastguard Worker
96*9880d681SAndroid Build Coastguard Workerdefine i16 @unaligned_i16_load(i16* %x) nounwind {
97*9880d681SAndroid Build Coastguard Workerentry:
98*9880d681SAndroid Build Coastguard Worker; ARM-STRICT-ALIGN: @unaligned_i16_load
99*9880d681SAndroid Build Coastguard Worker; ARM-STRICT-ALIGN: ldrb
100*9880d681SAndroid Build Coastguard Worker; ARM-STRICT-ALIGN: ldrb
101*9880d681SAndroid Build Coastguard Worker
102*9880d681SAndroid Build Coastguard Worker; THUMB-STRICT-ALIGN: @unaligned_i16_load
103*9880d681SAndroid Build Coastguard Worker; THUMB-STRICT-ALIGN: ldrb
104*9880d681SAndroid Build Coastguard Worker; THUMB-STRICT-ALIGN: ldrb
105*9880d681SAndroid Build Coastguard Worker
106*9880d681SAndroid Build Coastguard Worker  %0 = load i16, i16* %x, align 1
107*9880d681SAndroid Build Coastguard Worker  ret i16 %0
108*9880d681SAndroid Build Coastguard Worker}
109*9880d681SAndroid Build Coastguard Worker
110*9880d681SAndroid Build Coastguard Workerdefine void @unaligned_i32_store(i32 %x, i32* %y) nounwind {
111*9880d681SAndroid Build Coastguard Workerentry:
112*9880d681SAndroid Build Coastguard Worker; ARM-STRICT-ALIGN: @unaligned_i32_store
113*9880d681SAndroid Build Coastguard Worker; ARM-STRICT-ALIGN: strb
114*9880d681SAndroid Build Coastguard Worker; ARM-STRICT-ALIGN: strb
115*9880d681SAndroid Build Coastguard Worker; ARM-STRICT-ALIGN: strb
116*9880d681SAndroid Build Coastguard Worker; ARM-STRICT-ALIGN: strb
117*9880d681SAndroid Build Coastguard Worker
118*9880d681SAndroid Build Coastguard Worker; THUMB-STRICT-ALIGN: @unaligned_i32_store
119*9880d681SAndroid Build Coastguard Worker; THUMB-STRICT-ALIGN: strb
120*9880d681SAndroid Build Coastguard Worker; THUMB-STRICT-ALIGN: strb
121*9880d681SAndroid Build Coastguard Worker; THUMB-STRICT-ALIGN: strb
122*9880d681SAndroid Build Coastguard Worker; THUMB-STRICT-ALIGN: strb
123*9880d681SAndroid Build Coastguard Worker
124*9880d681SAndroid Build Coastguard Worker  store i32 %x, i32* %y, align 1
125*9880d681SAndroid Build Coastguard Worker  ret void
126*9880d681SAndroid Build Coastguard Worker}
127*9880d681SAndroid Build Coastguard Worker
128*9880d681SAndroid Build Coastguard Workerdefine i32 @unaligned_i32_load(i32* %x) nounwind {
129*9880d681SAndroid Build Coastguard Workerentry:
130*9880d681SAndroid Build Coastguard Worker; ARM-STRICT-ALIGN: @unaligned_i32_load
131*9880d681SAndroid Build Coastguard Worker; ARM-STRICT-ALIGN: ldrb
132*9880d681SAndroid Build Coastguard Worker; ARM-STRICT-ALIGN: ldrb
133*9880d681SAndroid Build Coastguard Worker; ARM-STRICT-ALIGN: ldrb
134*9880d681SAndroid Build Coastguard Worker; ARM-STRICT-ALIGN: ldrb
135*9880d681SAndroid Build Coastguard Worker
136*9880d681SAndroid Build Coastguard Worker; THUMB-STRICT-ALIGN: @unaligned_i32_load
137*9880d681SAndroid Build Coastguard Worker; THUMB-STRICT-ALIGN: ldrb
138*9880d681SAndroid Build Coastguard Worker; THUMB-STRICT-ALIGN: ldrb
139*9880d681SAndroid Build Coastguard Worker; THUMB-STRICT-ALIGN: ldrb
140*9880d681SAndroid Build Coastguard Worker; THUMB-STRICT-ALIGN: ldrb
141*9880d681SAndroid Build Coastguard Worker
142*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* %x, align 1
143*9880d681SAndroid Build Coastguard Worker  ret i32 %0
144*9880d681SAndroid Build Coastguard Worker}
145