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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -o - < %s | FileCheck %s
target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "armv8-unknown-linux-gnueabihf"
define <4 x float> @test(float* %A) {
; CHECK-LABEL: test:
; CHECK: @ %bb.0:
; CHECK-NEXT: vld1.32 {d16, d17}, [r0]!
; CHECK-NEXT: vld1.32 {d18, d19}, [r0]!
; CHECK-NEXT: vadd.f32 q8, q8, q9
; CHECK-NEXT: vld1.32 {d18, d19}, [r0]
; CHECK-NEXT: vadd.f32 q0, q8, q9
; CHECK-NEXT: bx lr
%X.ptr = bitcast float* %A to <4 x float>*
%X = load <4 x float>, <4 x float>* %X.ptr, align 4
%Y.ptr.elt = getelementptr inbounds float, float* %A, i32 4
%Y.ptr = bitcast float* %Y.ptr.elt to <4 x float>*
%Y = load <4 x float>, <4 x float>* %Y.ptr, align 4
%Z.ptr.elt = getelementptr inbounds float, float* %A, i32 8
%Z.ptr = bitcast float* %Z.ptr.elt to <4 x float>*
%Z = load <4 x float>, <4 x float>* %Z.ptr, align 4
%tmp.sum = fadd <4 x float> %X, %Y
%sum = fadd <4 x float> %tmp.sum, %Z
ret <4 x float> %sum
}
define <4 x float> @test_stride(float* %A) {
; CHECK-LABEL: test_stride:
; CHECK: @ %bb.0:
; CHECK-NEXT: mov r1, #24
; CHECK-NEXT: vld1.32 {d16, d17}, [r0], r1
; CHECK-NEXT: vld1.32 {d18, d19}, [r0], r1
; CHECK-NEXT: vadd.f32 q8, q8, q9
; CHECK-NEXT: vld1.32 {d18, d19}, [r0]
; CHECK-NEXT: vadd.f32 q0, q8, q9
; CHECK-NEXT: bx lr
%X.ptr = bitcast float* %A to <4 x float>*
%X = load <4 x float>, <4 x float>* %X.ptr, align 4
%Y.ptr.elt = getelementptr inbounds float, float* %A, i32 6
%Y.ptr = bitcast float* %Y.ptr.elt to <4 x float>*
%Y = load <4 x float>, <4 x float>* %Y.ptr, align 4
%Z.ptr.elt = getelementptr inbounds float, float* %A, i32 12
%Z.ptr = bitcast float* %Z.ptr.elt to <4 x float>*
%Z = load <4 x float>, <4 x float>* %Z.ptr, align 4
%tmp.sum = fadd <4 x float> %X, %Y
%sum = fadd <4 x float> %tmp.sum, %Z
ret <4 x float> %sum
}
define <4 x float> @test_stride_mixed(float* %A) {
; CHECK-LABEL: test_stride_mixed:
; CHECK: @ %bb.0:
; CHECK-NEXT: mov r1, #24
; CHECK-NEXT: vld1.32 {d16, d17}, [r0], r1
; CHECK-NEXT: vld1.32 {d18, d19}, [r0]!
; CHECK-NEXT: vadd.f32 q8, q8, q9
; CHECK-NEXT: vld1.32 {d18, d19}, [r0]
; CHECK-NEXT: vadd.f32 q0, q8, q9
; CHECK-NEXT: bx lr
%X.ptr = bitcast float* %A to <4 x float>*
%X = load <4 x float>, <4 x float>* %X.ptr, align 4
%Y.ptr.elt = getelementptr inbounds float, float* %A, i32 6
%Y.ptr = bitcast float* %Y.ptr.elt to <4 x float>*
%Y = load <4 x float>, <4 x float>* %Y.ptr, align 4
%Z.ptr.elt = getelementptr inbounds float, float* %A, i32 10
%Z.ptr = bitcast float* %Z.ptr.elt to <4 x float>*
%Z = load <4 x float>, <4 x float>* %Z.ptr, align 4
%tmp.sum = fadd <4 x float> %X, %Y
%sum = fadd <4 x float> %tmp.sum, %Z
ret <4 x float> %sum
}
; Refrain from using multiple stride registers
define <4 x float> @test_stride_noop(float* %A) {
; CHECK-LABEL: test_stride_noop:
; CHECK: @ %bb.0:
; CHECK-NEXT: mov r1, #24
; CHECK-NEXT: vld1.32 {d16, d17}, [r0], r1
; CHECK-NEXT: mov r1, #32
; CHECK-NEXT: vld1.32 {d18, d19}, [r0], r1
; CHECK-NEXT: vadd.f32 q8, q8, q9
; CHECK-NEXT: vld1.32 {d18, d19}, [r0]
; CHECK-NEXT: vadd.f32 q0, q8, q9
; CHECK-NEXT: bx lr
%X.ptr = bitcast float* %A to <4 x float>*
%X = load <4 x float>, <4 x float>* %X.ptr, align 4
%Y.ptr.elt = getelementptr inbounds float, float* %A, i32 6
%Y.ptr = bitcast float* %Y.ptr.elt to <4 x float>*
%Y = load <4 x float>, <4 x float>* %Y.ptr, align 4
%Z.ptr.elt = getelementptr inbounds float, float* %A, i32 14
%Z.ptr = bitcast float* %Z.ptr.elt to <4 x float>*
%Z = load <4 x float>, <4 x float>* %Z.ptr, align 4
%tmp.sum = fadd <4 x float> %X, %Y
%sum = fadd <4 x float> %tmp.sum, %Z
ret <4 x float> %sum
}
define <4 x float> @test_positive_initial_offset(float* %A) {
; CHECK-LABEL: test_positive_initial_offset:
; CHECK: @ %bb.0:
; CHECK-NEXT: add r0, r0, #32
; CHECK-NEXT: vld1.32 {d16, d17}, [r0]!
; CHECK-NEXT: vld1.32 {d18, d19}, [r0]!
; CHECK-NEXT: vadd.f32 q8, q8, q9
; CHECK-NEXT: vld1.32 {d18, d19}, [r0]
; CHECK-NEXT: vadd.f32 q0, q8, q9
; CHECK-NEXT: bx lr
%X.ptr.elt = getelementptr inbounds float, float* %A, i32 8
%X.ptr = bitcast float* %X.ptr.elt to <4 x float>*
%X = load <4 x float>, <4 x float>* %X.ptr, align 4
%Y.ptr.elt = getelementptr inbounds float, float* %A, i32 12
%Y.ptr = bitcast float* %Y.ptr.elt to <4 x float>*
%Y = load <4 x float>, <4 x float>* %Y.ptr, align 4
%Z.ptr.elt = getelementptr inbounds float, float* %A, i32 16
%Z.ptr = bitcast float* %Z.ptr.elt to <4 x float>*
%Z = load <4 x float>, <4 x float>* %Z.ptr, align 4
%tmp.sum = fadd <4 x float> %X, %Y
%sum = fadd <4 x float> %tmp.sum, %Z
ret <4 x float> %sum
}
define <4 x float> @test_negative_initial_offset(float* %A) {
; CHECK-LABEL: test_negative_initial_offset:
; CHECK: @ %bb.0:
; CHECK-NEXT: sub r0, r0, #64
; CHECK-NEXT: vld1.32 {d16, d17}, [r0]!
; CHECK-NEXT: vld1.32 {d18, d19}, [r0]!
; CHECK-NEXT: vadd.f32 q8, q8, q9
; CHECK-NEXT: vld1.32 {d18, d19}, [r0]
; CHECK-NEXT: vadd.f32 q0, q8, q9
; CHECK-NEXT: bx lr
%X.ptr.elt = getelementptr inbounds float, float* %A, i32 -16
%X.ptr = bitcast float* %X.ptr.elt to <4 x float>*
%X = load <4 x float>, <4 x float>* %X.ptr, align 4
%Y.ptr.elt = getelementptr inbounds float, float* %A, i32 -12
%Y.ptr = bitcast float* %Y.ptr.elt to <4 x float>*
%Y = load <4 x float>, <4 x float>* %Y.ptr, align 4
%Z.ptr.elt = getelementptr inbounds float, float* %A, i32 -8
%Z.ptr = bitcast float* %Z.ptr.elt to <4 x float>*
%Z = load <4 x float>, <4 x float>* %Z.ptr, align 4
%tmp.sum = fadd <4 x float> %X, %Y
%sum = fadd <4 x float> %tmp.sum, %Z
ret <4 x float> %sum
}
@global_float_array = external global [128 x float], align 4
define <4 x float> @test_global() {
; CHECK-LABEL: test_global:
; CHECK: @ %bb.0:
; CHECK-NEXT: movw r0, :lower16:global_float_array
; CHECK-NEXT: movt r0, :upper16:global_float_array
; CHECK-NEXT: add r0, r0, #32
; CHECK-NEXT: vld1.32 {d16, d17}, [r0]!
; CHECK-NEXT: vld1.32 {d18, d19}, [r0]!
; CHECK-NEXT: vadd.f32 q8, q8, q9
; CHECK-NEXT: vld1.32 {d18, d19}, [r0]
; CHECK-NEXT: vadd.f32 q0, q8, q9
; CHECK-NEXT: bx lr
%X = load <4 x float>, <4 x float>* bitcast (float* getelementptr inbounds ([128 x float], [128 x float]* @global_float_array, i32 0, i32 8) to <4 x float>*), align 4
%Y = load <4 x float>, <4 x float>* bitcast (float* getelementptr inbounds ([128 x float], [128 x float]* @global_float_array, i32 0, i32 12) to <4 x float>*), align 4
%Z = load <4 x float>, <4 x float>* bitcast (float* getelementptr inbounds ([128 x float], [128 x float]* @global_float_array, i32 0, i32 16) to <4 x float>*), align 4
%tmp.sum = fadd <4 x float> %X, %Y
%sum = fadd <4 x float> %tmp.sum, %Z
ret <4 x float> %sum
}
define <4 x float> @test_stack() {
; Use huge alignment to test that ADD would not be converted to OR
; CHECK-LABEL: test_stack:
; CHECK: @ %bb.0:
; CHECK-NEXT: .save {r4, r10, r11, lr}
; CHECK-NEXT: push {r4, r10, r11, lr}
; CHECK-NEXT: .setfp r11, sp, #8
; CHECK-NEXT: add r11, sp, #8
; CHECK-NEXT: .pad #240
; CHECK-NEXT: sub sp, sp, #240
; CHECK-NEXT: bfc sp, #0, #7
; CHECK-NEXT: mov r4, sp
; CHECK-NEXT: mov r0, r4
; CHECK-NEXT: bl external_function
; CHECK-NEXT: vld1.32 {d16, d17}, [r4:128]!
; CHECK-NEXT: vld1.32 {d18, d19}, [r4:128]!
; CHECK-NEXT: vadd.f32 q8, q8, q9
; CHECK-NEXT: vld1.64 {d18, d19}, [r4:128]
; CHECK-NEXT: vadd.f32 q0, q8, q9
; CHECK-NEXT: sub sp, r11, #8
; CHECK-NEXT: pop {r4, r10, r11, pc}
%array = alloca [32 x float], align 128
%arraydecay = getelementptr inbounds [32 x float], [32 x float]* %array, i32 0, i32 0
call void @external_function(float* %arraydecay)
%X.ptr = bitcast [32 x float]* %array to <4 x float>*
%X = load <4 x float>, <4 x float>* %X.ptr, align 4
%Y.ptr.elt = getelementptr inbounds [32 x float], [32 x float]* %array, i32 0, i32 4
%Y.ptr = bitcast float* %Y.ptr.elt to <4 x float>*
%Y = load <4 x float>, <4 x float>* %Y.ptr, align 4
%Z.ptr.elt = getelementptr inbounds [32 x float], [32 x float]* %array, i32 0, i32 8
%Z.ptr = bitcast float* %Z.ptr.elt to <4 x float>*
%Z = load <4 x float>, <4 x float>* %Z.ptr, align 4
%tmp.sum = fadd <4 x float> %X, %Y
%sum = fadd <4 x float> %tmp.sum, %Z
ret <4 x float> %sum
}
define <2 x double> @test_double(double* %A) {
; CHECK-LABEL: test_double:
; CHECK: @ %bb.0:
; CHECK-NEXT: add r0, r0, #64
; CHECK-NEXT: vld1.64 {d16, d17}, [r0]!
; CHECK-NEXT: vld1.64 {d18, d19}, [r0]!
; CHECK-NEXT: vadd.f64 d20, d17, d19
; CHECK-NEXT: vadd.f64 d16, d16, d18
; CHECK-NEXT: vld1.64 {d22, d23}, [r0]
; CHECK-NEXT: vadd.f64 d1, d20, d23
; CHECK-NEXT: vadd.f64 d0, d16, d22
; CHECK-NEXT: bx lr
%X.ptr.elt = getelementptr inbounds double, double* %A, i32 8
%X.ptr = bitcast double* %X.ptr.elt to <2 x double>*
%X = load <2 x double>, <2 x double>* %X.ptr, align 8
%Y.ptr.elt = getelementptr inbounds double, double* %A, i32 10
%Y.ptr = bitcast double* %Y.ptr.elt to <2 x double>*
%Y = load <2 x double>, <2 x double>* %Y.ptr, align 8
%Z.ptr.elt = getelementptr inbounds double, double* %A, i32 12
%Z.ptr = bitcast double* %Z.ptr.elt to <2 x double>*
%Z = load <2 x double>, <2 x double>* %Z.ptr, align 8
%tmp.sum = fadd <2 x double> %X, %Y
%sum = fadd <2 x double> %tmp.sum, %Z
ret <2 x double> %sum
}
define void @test_various_instructions(float* %A) {
; CHECK-LABEL: test_various_instructions:
; CHECK: @ %bb.0:
; CHECK-NEXT: vld1.32 {d16, d17}, [r0]!
; CHECK-NEXT: vld1.32 {d18, d19}, [r0]!
; CHECK-NEXT: vadd.f32 q8, q8, q9
; CHECK-NEXT: vst1.32 {d16, d17}, [r0]
; CHECK-NEXT: bx lr
%X.ptr = bitcast float* %A to i8*
%X = call <4 x float> @llvm.arm.neon.vld1.v4f32.p0i8(i8* %X.ptr, i32 1)
%Y.ptr.elt = getelementptr inbounds float, float* %A, i32 4
%Y.ptr = bitcast float* %Y.ptr.elt to <4 x float>*
%Y = load <4 x float>, <4 x float>* %Y.ptr, align 4
%Z.ptr.elt = getelementptr inbounds float, float* %A, i32 8
%Z.ptr = bitcast float* %Z.ptr.elt to i8*
%Z = fadd <4 x float> %X, %Y
tail call void @llvm.arm.neon.vst1.p0i8.v4f32(i8* nonnull %Z.ptr, <4 x float> %Z, i32 4)
ret void
}
define void @test_lsr_geps(float* %a, float* %b, i32 %n) {
; CHECK-LABEL: test_lsr_geps:
; CHECK: @ %bb.0: @ %entry
; CHECK-NEXT: cmp r2, #1
; CHECK-NEXT: bxlt lr
; CHECK-NEXT: .LBB10_1: @ %for.body.preheader
; CHECK-NEXT: mov r12, #0
; CHECK-NEXT: .LBB10_2: @ %for.body
; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
; CHECK-NEXT: add r3, r0, r12
; CHECK-NEXT: subs r2, r2, #1
; CHECK-NEXT: vld1.32 {d16, d17}, [r3]!
; CHECK-NEXT: vld1.32 {d18, d19}, [r3]!
; CHECK-NEXT: vld1.32 {d20, d21}, [r3]!
; CHECK-NEXT: vld1.32 {d22, d23}, [r3]
; CHECK-NEXT: add r3, r1, r12
; CHECK-NEXT: add r12, r12, #64
; CHECK-NEXT: vst1.32 {d16, d17}, [r3]!
; CHECK-NEXT: vst1.32 {d18, d19}, [r3]!
; CHECK-NEXT: vst1.32 {d20, d21}, [r3]!
; CHECK-NEXT: vst1.32 {d22, d23}, [r3]
; CHECK-NEXT: bne .LBB10_2
; CHECK-NEXT: @ %bb.3: @ %for.cond.cleanup
; CHECK-NEXT: bx lr
entry:
%cmp61 = icmp sgt i32 %n, 0
br i1 %cmp61, label %for.body.preheader, label %for.cond.cleanup
for.body.preheader:
br label %for.body
for.cond.cleanup:
ret void
for.body:
%lsr.iv1 = phi i32 [ 0, %for.body.preheader ], [ %lsr.iv.next2, %for.body ]
%lsr.iv = phi i32 [ %n, %for.body.preheader ], [ %lsr.iv.next, %for.body ]
%0 = bitcast float* %a to i8*
%1 = bitcast float* %b to i8*
%uglygep19 = getelementptr i8, i8* %0, i32 %lsr.iv1
%uglygep1920 = bitcast i8* %uglygep19 to <4 x float>*
%2 = load <4 x float>, <4 x float>* %uglygep1920, align 4
%uglygep16 = getelementptr i8, i8* %0, i32 %lsr.iv1
%uglygep1617 = bitcast i8* %uglygep16 to <4 x float>*
%scevgep18 = getelementptr <4 x float>, <4 x float>* %uglygep1617, i32 1
%3 = load <4 x float>, <4 x float>* %scevgep18, align 4
%uglygep13 = getelementptr i8, i8* %0, i32 %lsr.iv1
%uglygep1314 = bitcast i8* %uglygep13 to <4 x float>*
%scevgep15 = getelementptr <4 x float>, <4 x float>* %uglygep1314, i32 2
%4 = load <4 x float>, <4 x float>* %scevgep15, align 4
%uglygep10 = getelementptr i8, i8* %0, i32 %lsr.iv1
%uglygep1011 = bitcast i8* %uglygep10 to <4 x float>*
%scevgep12 = getelementptr <4 x float>, <4 x float>* %uglygep1011, i32 3
%5 = load <4 x float>, <4 x float>* %scevgep12, align 4
%uglygep8 = getelementptr i8, i8* %1, i32 %lsr.iv1
tail call void @llvm.arm.neon.vst1.p0i8.v4f32(i8* %uglygep8, <4 x float> %2, i32 4)
%uglygep6 = getelementptr i8, i8* %1, i32 %lsr.iv1
%scevgep7 = getelementptr i8, i8* %uglygep6, i32 16
tail call void @llvm.arm.neon.vst1.p0i8.v4f32(i8* nonnull %scevgep7, <4 x float> %3, i32 4)
%uglygep4 = getelementptr i8, i8* %1, i32 %lsr.iv1
%scevgep5 = getelementptr i8, i8* %uglygep4, i32 32
tail call void @llvm.arm.neon.vst1.p0i8.v4f32(i8* nonnull %scevgep5, <4 x float> %4, i32 4)
%uglygep = getelementptr i8, i8* %1, i32 %lsr.iv1
%scevgep = getelementptr i8, i8* %uglygep, i32 48
tail call void @llvm.arm.neon.vst1.p0i8.v4f32(i8* nonnull %scevgep, <4 x float> %5, i32 4)
%lsr.iv.next = add i32 %lsr.iv, -1
%lsr.iv.next2 = add nuw i32 %lsr.iv1, 64
%exitcond.not = icmp eq i32 %lsr.iv.next, 0
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
}
declare void @external_function(float*)
declare <4 x float> @llvm.arm.neon.vld1.v4f32.p0i8(i8*, i32) nounwind readonly
declare void @llvm.arm.neon.vst1.p0i8.v4f32(i8*, <4 x float>, i32) nounwind argmemonly
|