File: arm64-stp.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (212 lines) | stat: -rw-r--r-- 7,110 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
; RUN: llc < %s -mtriple=arm64-eabi -aarch64-enable-stp-suppress=false -verify-machineinstrs -mcpu=cyclone -aarch64-enable-sink-fold=true | FileCheck %s

define void @stp_int(i32 %a, i32 %b, ptr nocapture %p) nounwind {
; CHECK-LABEL: stp_int:
; CHECK:       // %bb.0:
; CHECK-NEXT:    stp w0, w1, [x2]
; CHECK-NEXT:    ret
  store i32 %a, ptr %p, align 4
  %add.ptr = getelementptr inbounds i32, ptr %p, i64 1
  store i32 %b, ptr %add.ptr, align 4
  ret void
}

define void @stp_long(i64 %a, i64 %b, ptr nocapture %p) nounwind {
; CHECK-LABEL: stp_long:
; CHECK:       // %bb.0:
; CHECK-NEXT:    stp x0, x1, [x2]
; CHECK-NEXT:    ret
  store i64 %a, ptr %p, align 8
  %add.ptr = getelementptr inbounds i64, ptr %p, i64 1
  store i64 %b, ptr %add.ptr, align 8
  ret void
}

define void @stp_float(float %a, float %b, ptr nocapture %p) nounwind {
; CHECK-LABEL: stp_float:
; CHECK:       // %bb.0:
; CHECK-NEXT:    stp s0, s1, [x0]
; CHECK-NEXT:    ret
  store float %a, ptr %p, align 4
  %add.ptr = getelementptr inbounds float, ptr %p, i64 1
  store float %b, ptr %add.ptr, align 4
  ret void
}

define void @stp_double(double %a, double %b, ptr nocapture %p) nounwind {
; CHECK-LABEL: stp_double:
; CHECK:       // %bb.0:
; CHECK-NEXT:    stp d0, d1, [x0]
; CHECK-NEXT:    ret
  store double %a, ptr %p, align 8
  %add.ptr = getelementptr inbounds double, ptr %p, i64 1
  store double %b, ptr %add.ptr, align 8
  ret void
}

define void @stp_doublex2(<2 x double> %a, <2 x double> %b, ptr nocapture %p) nounwind {
; CHECK-LABEL: stp_doublex2:
; CHECK:       // %bb.0:
; CHECK-NEXT:    stp q0, q1, [x0]
; CHECK-NEXT:    ret
  store <2 x double> %a, ptr %p, align 16
  %add.ptr = getelementptr inbounds <2 x double>, ptr %p, i64 1
  store <2 x double> %b, ptr %add.ptr, align 16
  ret void
}

; Test the load/store optimizer---combine ldurs into a ldp, if appropriate
define void @stur_int(i32 %a, i32 %b, ptr nocapture %p) nounwind {
; CHECK-LABEL: stur_int:
; CHECK:       // %bb.0:
; CHECK-NEXT:    stp w1, w0, [x2, #-8]
; CHECK-NEXT:    ret
  %p1 = getelementptr inbounds i32, ptr %p, i32 -1
  store i32 %a, ptr %p1, align 2
  %p2 = getelementptr inbounds i32, ptr %p, i32 -2
  store i32 %b, ptr %p2, align 2
  ret void
}

define void @stur_long(i64 %a, i64 %b, ptr nocapture %p) nounwind {
; CHECK-LABEL: stur_long:
; CHECK:       // %bb.0:
; CHECK-NEXT:    stp x1, x0, [x2, #-16]
; CHECK-NEXT:    ret
  %p1 = getelementptr inbounds i64, ptr %p, i32 -1
  store i64 %a, ptr %p1, align 2
  %p2 = getelementptr inbounds i64, ptr %p, i32 -2
  store i64 %b, ptr %p2, align 2
  ret void
}

define void @stur_float(float %a, float %b, ptr nocapture %p) nounwind {
; CHECK-LABEL: stur_float:
; CHECK:       // %bb.0:
; CHECK-NEXT:    stp s1, s0, [x0, #-8]
; CHECK-NEXT:    ret
  %p1 = getelementptr inbounds float, ptr %p, i32 -1
  store float %a, ptr %p1, align 2
  %p2 = getelementptr inbounds float, ptr %p, i32 -2
  store float %b, ptr %p2, align 2
  ret void
}

define void @stur_double(double %a, double %b, ptr nocapture %p) nounwind {
; CHECK-LABEL: stur_double:
; CHECK:       // %bb.0:
; CHECK-NEXT:    stp d1, d0, [x0, #-16]
; CHECK-NEXT:    ret
  %p1 = getelementptr inbounds double, ptr %p, i32 -1
  store double %a, ptr %p1, align 2
  %p2 = getelementptr inbounds double, ptr %p, i32 -2
  store double %b, ptr %p2, align 2
  ret void
}

define void @stur_doublex2(<2 x double> %a, <2 x double> %b, ptr nocapture %p) nounwind {
; CHECK-LABEL: stur_doublex2:
; CHECK:       // %bb.0:
; CHECK-NEXT:    stp q1, q0, [x0, #-32]
; CHECK-NEXT:    ret
  %p1 = getelementptr inbounds <2 x double>, ptr %p, i32 -1
  store <2 x double> %a, ptr %p1, align 2
  %p2 = getelementptr inbounds <2 x double>, ptr %p, i32 -2
  store <2 x double> %b, ptr %p2, align 2
  ret void
}

define void @splat_v4i32(i32 %v, ptr %p) {
; CHECK-LABEL: splat_v4i32:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    dup v0.4s, w0
; CHECK-NEXT:    str q0, [x1]
; CHECK-NEXT:    ret
entry:
  %p17 = insertelement <4 x i32> undef, i32 %v, i32 0
  %p18 = insertelement <4 x i32> %p17, i32 %v, i32 1
  %p19 = insertelement <4 x i32> %p18, i32 %v, i32 2
  %p20 = insertelement <4 x i32> %p19, i32 %v, i32 3
  store <4 x i32> %p20, ptr %p, align 4
  ret void
}

; Check that a non-splat store that is storing a vector created by 4
; insertelements that is not a splat vector does not get split.
define void @nosplat_v4i32(i32 %v, ptr %p) {
; CHECK-LABEL: nosplat_v4i32:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    sub sp, sp, #16
; CHECK-NEXT:    .cfi_def_cfa_offset 16
; CHECK-NEXT:    // kill: def $w0 killed $w0 def $x0
; CHECK-NEXT:    mov x8, sp
; CHECK-NEXT:    bfi x8, x0, #2, #2
; CHECK-NEXT:    str w0, [x8]
; CHECK-NEXT:    ldr q0, [sp]
; CHECK-NEXT:    mov v0.s[1], w0
; CHECK-NEXT:    mov v0.s[2], w0
; CHECK-NEXT:    mov v0.s[3], w0
; CHECK-NEXT:    str q0, [x1]
; CHECK-NEXT:    add sp, sp, #16
; CHECK-NEXT:    ret
entry:
  %p17 = insertelement <4 x i32> undef, i32 %v, i32 %v
  %p18 = insertelement <4 x i32> %p17, i32 %v, i32 1
  %p19 = insertelement <4 x i32> %p18, i32 %v, i32 2
  %p20 = insertelement <4 x i32> %p19, i32 %v, i32 3
  store <4 x i32> %p20, ptr %p, align 4
  ret void
}

; Check that a non-splat store that is storing a vector created by 4
; insertelements that is not a splat vector does not get split.
define void @nosplat2_v4i32(i32 %v, ptr %p, <4 x i32> %vin) {
; CHECK-LABEL: nosplat2_v4i32:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    mov v0.s[1], w0
; CHECK-NEXT:    mov v0.s[2], w0
; CHECK-NEXT:    mov v0.s[3], w0
; CHECK-NEXT:    str q0, [x1]
; CHECK-NEXT:    ret
entry:
  %p18 = insertelement <4 x i32> %vin, i32 %v, i32 1
  %p19 = insertelement <4 x i32> %p18, i32 %v, i32 2
  %p20 = insertelement <4 x i32> %p19, i32 %v, i32 3
  store <4 x i32> %p20, ptr %p, align 4
  ret void
}

; Read of %b to compute %tmp2 shouldn't prevent formation of stp
define i32 @stp_int_rar_hazard(i32 %a, i32 %b, ptr nocapture %p) nounwind {
; CHECK-LABEL: stp_int_rar_hazard:
; CHECK:       // %bb.0:
; CHECK-NEXT:    ldr w8, [x2, #8]
; CHECK-NEXT:    stp w0, w1, [x2]
; CHECK-NEXT:    add w0, w8, w1
; CHECK-NEXT:    ret
  store i32 %a, ptr %p, align 4
  %ld.ptr = getelementptr inbounds i32, ptr %p, i64 2
  %tmp = load i32, ptr %ld.ptr, align 4
  %tmp2 = add i32 %tmp, %b
  %add.ptr = getelementptr inbounds i32, ptr %p, i64 1
  store i32 %b, ptr %add.ptr, align 4
  ret i32 %tmp2
}

; Read of %b to compute %tmp2 shouldn't prevent formation of stp
define i32 @stp_int_rar_hazard_after(i32 %w0, i32 %a, i32 %b, ptr nocapture %p) nounwind {
; CHECK-LABEL: stp_int_rar_hazard_after:
; CHECK:       // %bb.0:
; CHECK-NEXT:    ldr w8, [x3, #4]
; CHECK-NEXT:    stp w1, w2, [x3]
; CHECK-NEXT:    add w0, w8, w2
; CHECK-NEXT:    ret
  store i32 %a, ptr %p, align 4
  %ld.ptr = getelementptr inbounds i32, ptr %p, i64 1
  %tmp = load i32, ptr %ld.ptr, align 4
  %tmp2 = add i32 %tmp, %b
  %add.ptr = getelementptr inbounds i32, ptr %p, i64 1
  store i32 %b, ptr %add.ptr, align 4
  ret i32 %tmp2
}