1 ; RUN: llc -march=hexagon -fp-contract=fast -disable-hexagon-peephole -disable-hexagon-amodeopt < %s | FileCheck %s
3 ; The test checks for various addressing modes for floating point loads/stores.
5 %struct.matrix_paramsGlob = type { [50 x i8], i16, [50 x float] }
6 %struct.matrix_params = type { [50 x i8], i16, ptr }
7 %struct.matrix_params2 = type { i16, [50 x [50 x float]] }
9 @globB = common global %struct.matrix_paramsGlob zeroinitializer, align 4
10 @globA = common global %struct.matrix_paramsGlob zeroinitializer, align 4
11 @b = common global float 0.000000e+00, align 4
12 @a = common global float 0.000000e+00, align 4
15 ; CHECK: [[REG11:(r[0-9]+)]] = memw(r{{[0-9]+}}+r{{[0-9]+}}<<#2)
16 ; CHECK: [[REG12:(r[0-9]+)]] += sfmpy({{.*}}[[REG11]]
17 ; CHECK: memw(r{{[0-9]+}}+r{{[0-9]+}}<<#2) = [[REG12]].new
19 ; Function Attrs: norecurse nounwind
20 define void @test1(ptr nocapture readonly %params, i32 %col1) {
22 %matrixA = getelementptr inbounds %struct.matrix_params, ptr %params, i32 0, i32 2
23 %0 = load ptr, ptr %matrixA, align 4
24 %arrayidx = getelementptr inbounds ptr, ptr %0, i32 2
25 %1 = load ptr, ptr %arrayidx, align 4
26 %arrayidx1 = getelementptr inbounds float, ptr %1, i32 %col1
27 %2 = load float, ptr %arrayidx1, align 4
28 %mul = fmul float %2, 2.000000e+01
29 %add = fadd float %mul, 1.000000e+01
30 %arrayidx3 = getelementptr inbounds ptr, ptr %0, i32 5
31 %3 = load ptr, ptr %arrayidx3, align 4
32 %arrayidx4 = getelementptr inbounds float, ptr %3, i32 %col1
33 store float %add, ptr %arrayidx4, align 4
38 ; CHECK: [[REG21:(r[0-9]+)]] = memw(##globB+92)
39 ; CHECK: [[REG22:(r[0-9]+)]] = sfadd({{.*}}[[REG21]]
40 ; CHECK: memw(##globA+84) = [[REG22]]
42 ; Function Attrs: norecurse nounwind
43 define void @test2(ptr nocapture readonly %params, i32 %col1) {
45 %matrixA = getelementptr inbounds %struct.matrix_params, ptr %params, i32 0, i32 2
46 %0 = load ptr, ptr %matrixA, align 4
47 %1 = load ptr, ptr %0, align 4
48 %arrayidx1 = getelementptr inbounds float, ptr %1, i32 %col1
49 %2 = load float, ptr %arrayidx1, align 4
50 %3 = load float, ptr getelementptr inbounds (%struct.matrix_paramsGlob, ptr @globB, i32 0, i32 2, i32 10), align 4
51 %add = fadd float %2, %3
52 store float %add, ptr getelementptr inbounds (%struct.matrix_paramsGlob, ptr @globA, i32 0, i32 2, i32 8), align 4
57 ; CHECK: [[REG31:(r[0-9]+)]] = memw(gp+#b)
58 ; CHECK: [[REG32:(r[0-9]+)]] = sfadd({{.*}}[[REG31]]
59 ; CHECK: memw(gp+#a) = [[REG32]]
61 ; Function Attrs: norecurse nounwind
62 define void @test3(ptr nocapture readonly %params, i32 %col1) {
64 %matrixA = getelementptr inbounds %struct.matrix_params, ptr %params, i32 0, i32 2
65 %0 = load ptr, ptr %matrixA, align 4
66 %1 = load ptr, ptr %0, align 4
67 %arrayidx1 = getelementptr inbounds float, ptr %1, i32 %col1
68 %2 = load float, ptr %arrayidx1, align 4
69 %3 = load float, ptr @b, align 4
70 %add = fadd float %2, %3
71 store float %add, ptr @a, align 4
76 ; CHECK: [[REG41:(r[0-9]+)]] = memw(r0<<#2+##globB+52)
77 ; CHECK: [[REG42:(r[0-9]+)]] = sfadd({{.*}}[[REG41]]
78 ; CHECK: memw(r0<<#2+##globA+60) = [[REG42]]
79 ; Function Attrs: noinline norecurse nounwind
80 define void @test4(i32 %col1) {
82 %arrayidx = getelementptr inbounds %struct.matrix_paramsGlob, ptr @globB, i32 0, i32 2, i32 %col1
83 %0 = load float, ptr %arrayidx, align 4
84 %add = fadd float %0, 0.000000e+00
85 %add1 = add nsw i32 %col1, 2
86 %arrayidx2 = getelementptr inbounds %struct.matrix_paramsGlob, ptr @globA, i32 0, i32 2, i32 %add1
87 store float %add, ptr %arrayidx2, align 4