blob: d770582ecab997ba1db072e683965883c5546b07 [file] [log] [blame]
Krzysztof Parzyszekbd8ef4b2016-08-19 13:34:31 +00001; RUN: llc -march=hexagon -fp-contract=fast -disable-hexagon-peephole -disable-hexagon-amodeopt < %s | FileCheck %s
2
3; The test checks for various addressing modes for floating point loads/stores.
4
5%struct.matrix_paramsGlob = type { [50 x i8], i16, [50 x float] }
6%struct.matrix_params = type { [50 x i8], i16, float** }
7%struct.matrix_params2 = type { i16, [50 x [50 x float]] }
8
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
13
14; CHECK-LABEL: test1
Krzysztof Parzyszeka72fad92017-02-10 15:33:13 +000015; CHECK: [[REG11:(r[0-9]+)]] = memw(r{{[0-9]+}}+r{{[0-9]+}}<<#2)
Krzysztof Parzyszekbd8ef4b2016-08-19 13:34:31 +000016; CHECK: [[REG12:(r[0-9]+)]] += sfmpy({{.*}}[[REG11]]
Krzysztof Parzyszeka72fad92017-02-10 15:33:13 +000017; CHECK: memw(r{{[0-9]+}}+r{{[0-9]+}}<<#2) = [[REG12]].new
Krzysztof Parzyszekbd8ef4b2016-08-19 13:34:31 +000018
19; Function Attrs: norecurse nounwind
20define void @test1(%struct.matrix_params* nocapture readonly %params, i32 %col1) {
21entry:
22 %matrixA = getelementptr inbounds %struct.matrix_params, %struct.matrix_params* %params, i32 0, i32 2
23 %0 = load float**, float*** %matrixA, align 4
24 %arrayidx = getelementptr inbounds float*, float** %0, i32 2
25 %1 = load float*, float** %arrayidx, align 4
26 %arrayidx1 = getelementptr inbounds float, float* %1, i32 %col1
27 %2 = load float, float* %arrayidx1, align 4
28 %mul = fmul float %2, 2.000000e+01
29 %add = fadd float %mul, 1.000000e+01
30 %arrayidx3 = getelementptr inbounds float*, float** %0, i32 5
31 %3 = load float*, float** %arrayidx3, align 4
32 %arrayidx4 = getelementptr inbounds float, float* %3, i32 %col1
33 store float %add, float* %arrayidx4, align 4
34 ret void
35}
36
37; CHECK-LABEL: test2
Krzysztof Parzyszeka72fad92017-02-10 15:33:13 +000038; CHECK: [[REG21:(r[0-9]+)]] = memw(##globB+92)
Krzysztof Parzyszekbd8ef4b2016-08-19 13:34:31 +000039; CHECK: [[REG22:(r[0-9]+)]] = sfadd({{.*}}[[REG21]]
40; CHECK: memw(##globA+84) = [[REG22]]
41
42; Function Attrs: norecurse nounwind
43define void @test2(%struct.matrix_params* nocapture readonly %params, i32 %col1) {
44entry:
45 %matrixA = getelementptr inbounds %struct.matrix_params, %struct.matrix_params* %params, i32 0, i32 2
46 %0 = load float**, float*** %matrixA, align 4
47 %1 = load float*, float** %0, align 4
48 %arrayidx1 = getelementptr inbounds float, float* %1, i32 %col1
49 %2 = load float, float* %arrayidx1, align 4
50 %3 = load float, float* getelementptr inbounds (%struct.matrix_paramsGlob, %struct.matrix_paramsGlob* @globB, i32 0, i32 2, i32 10), align 4
51 %add = fadd float %2, %3
52 store float %add, float* getelementptr inbounds (%struct.matrix_paramsGlob, %struct.matrix_paramsGlob* @globA, i32 0, i32 2, i32 8), align 4
53 ret void
54}
55
56; CHECK-LABEL: test3
Krzysztof Parzyszeka72fad92017-02-10 15:33:13 +000057; CHECK: [[REG31:(r[0-9]+)]] = memw(gp+#b)
Krzysztof Parzyszekbd8ef4b2016-08-19 13:34:31 +000058; CHECK: [[REG32:(r[0-9]+)]] = sfadd({{.*}}[[REG31]]
Krzysztof Parzyszek5b4a6b62017-02-06 23:18:57 +000059; CHECK: memw(gp+#a) = [[REG32]]
Krzysztof Parzyszekbd8ef4b2016-08-19 13:34:31 +000060
61; Function Attrs: norecurse nounwind
62define void @test3(%struct.matrix_params* nocapture readonly %params, i32 %col1) {
63entry:
64 %matrixA = getelementptr inbounds %struct.matrix_params, %struct.matrix_params* %params, i32 0, i32 2
65 %0 = load float**, float*** %matrixA, align 4
66 %1 = load float*, float** %0, align 4
67 %arrayidx1 = getelementptr inbounds float, float* %1, i32 %col1
68 %2 = load float, float* %arrayidx1, align 4
69 %3 = load float, float* @b, align 4
70 %add = fadd float %2, %3
71 store float %add, float* @a, align 4
72 ret void
73}
74
75; CHECK-LABEL: test4
Krzysztof Parzyszeka72fad92017-02-10 15:33:13 +000076; CHECK: [[REG41:(r[0-9]+)]] = memw(r0<<#2+##globB+52)
Krzysztof Parzyszekbd8ef4b2016-08-19 13:34:31 +000077; CHECK: [[REG42:(r[0-9]+)]] = sfadd({{.*}}[[REG41]]
Krzysztof Parzyszeka72fad92017-02-10 15:33:13 +000078; CHECK: memw(r0<<#2+##globA+60) = [[REG42]]
Krzysztof Parzyszekbd8ef4b2016-08-19 13:34:31 +000079; Function Attrs: noinline norecurse nounwind
80define void @test4(i32 %col1) {
81entry:
82 %arrayidx = getelementptr inbounds %struct.matrix_paramsGlob, %struct.matrix_paramsGlob* @globB, i32 0, i32 2, i32 %col1
83 %0 = load float, float* %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, %struct.matrix_paramsGlob* @globA, i32 0, i32 2, i32 %add1
87 store float %add, float* %arrayidx2, align 4
88 ret void
89}