R600: Fix vector FMA
[oota-llvm.git] / test / CodeGen / R600 / fma.ll
1 ; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2
3 declare float @llvm.fma.f32(float, float, float) nounwind readnone
4 declare <2 x float> @llvm.fma.v2f32(<2 x float>, <2 x float>, <2 x float>) nounwind readnone
5 declare <4 x float> @llvm.fma.v4f32(<4 x float>, <4 x float>, <4 x float>) nounwind readnone
6
7 declare double @llvm.fma.f64(double, double, double) nounwind readnone
8 declare <2 x double> @llvm.fma.v2f64(<2 x double>, <2 x double>, <2 x double>) nounwind readnone
9 declare <4 x double> @llvm.fma.v4f64(<4 x double>, <4 x double>, <4 x double>) nounwind readnone
10
11 ; FUNC-LABEL: @fma_f32
12 ; SI: V_FMA_F32 {{v[0-9]+, v[0-9]+, v[0-9]+, v[0-9]+}}
13 define void @fma_f32(float addrspace(1)* %out, float addrspace(1)* %in1,
14                      float addrspace(1)* %in2, float addrspace(1)* %in3) {
15    %r0 = load float addrspace(1)* %in1
16    %r1 = load float addrspace(1)* %in2
17    %r2 = load float addrspace(1)* %in3
18    %r3 = tail call float @llvm.fma.f32(float %r0, float %r1, float %r2)
19    store float %r3, float addrspace(1)* %out
20    ret void
21 }
22
23 ; FUNC-LABEL: @fma_v2f32
24 ; SI: V_FMA_F32
25 ; SI: V_FMA_F32
26 define void @fma_v2f32(<2 x float> addrspace(1)* %out, <2 x float> addrspace(1)* %in1,
27                        <2 x float> addrspace(1)* %in2, <2 x float> addrspace(1)* %in3) {
28    %r0 = load <2 x float> addrspace(1)* %in1
29    %r1 = load <2 x float> addrspace(1)* %in2
30    %r2 = load <2 x float> addrspace(1)* %in3
31    %r3 = tail call <2 x float> @llvm.fma.v2f32(<2 x float> %r0, <2 x float> %r1, <2 x float> %r2)
32    store <2 x float> %r3, <2 x float> addrspace(1)* %out
33    ret void
34 }
35
36 ; FUNC-LABEL: @fma_v4f32
37 ; SI: V_FMA_F32
38 ; SI: V_FMA_F32
39 ; SI: V_FMA_F32
40 ; SI: V_FMA_F32
41 define void @fma_v4f32(<4 x float> addrspace(1)* %out, <4 x float> addrspace(1)* %in1,
42                        <4 x float> addrspace(1)* %in2, <4 x float> addrspace(1)* %in3) {
43    %r0 = load <4 x float> addrspace(1)* %in1
44    %r1 = load <4 x float> addrspace(1)* %in2
45    %r2 = load <4 x float> addrspace(1)* %in3
46    %r3 = tail call <4 x float> @llvm.fma.v4f32(<4 x float> %r0, <4 x float> %r1, <4 x float> %r2)
47    store <4 x float> %r3, <4 x float> addrspace(1)* %out
48    ret void
49 }
50
51 ; FUNC-LABEL: @fma_f64
52 ; SI: V_FMA_F64 {{v\[[0-9]+:[0-9]+\], v\[[0-9]+:[0-9]+\], v\[[0-9]+:[0-9]+\], v\[[0-9]+:[0-9]+\]}}
53 define void @fma_f64(double addrspace(1)* %out, double addrspace(1)* %in1,
54                      double addrspace(1)* %in2, double addrspace(1)* %in3) {
55    %r0 = load double addrspace(1)* %in1
56    %r1 = load double addrspace(1)* %in2
57    %r2 = load double addrspace(1)* %in3
58    %r3 = tail call double @llvm.fma.f64(double %r0, double %r1, double %r2)
59    store double %r3, double addrspace(1)* %out
60    ret void
61 }
62
63 ; FUNC-LABEL: @fma_v2f64
64 ; SI: V_FMA_F64
65 ; SI: V_FMA_F64
66 define void @fma_v2f64(<2 x double> addrspace(1)* %out, <2 x double> addrspace(1)* %in1,
67                        <2 x double> addrspace(1)* %in2, <2 x double> addrspace(1)* %in3) {
68    %r0 = load <2 x double> addrspace(1)* %in1
69    %r1 = load <2 x double> addrspace(1)* %in2
70    %r2 = load <2 x double> addrspace(1)* %in3
71    %r3 = tail call <2 x double> @llvm.fma.v2f64(<2 x double> %r0, <2 x double> %r1, <2 x double> %r2)
72    store <2 x double> %r3, <2 x double> addrspace(1)* %out
73    ret void
74 }
75
76 ; FUNC-LABEL: @fma_v4f64
77 ; SI: V_FMA_F64
78 ; SI: V_FMA_F64
79 ; SI: V_FMA_F64
80 ; SI: V_FMA_F64
81 define void @fma_v4f64(<4 x double> addrspace(1)* %out, <4 x double> addrspace(1)* %in1,
82                        <4 x double> addrspace(1)* %in2, <4 x double> addrspace(1)* %in3) {
83    %r0 = load <4 x double> addrspace(1)* %in1
84    %r1 = load <4 x double> addrspace(1)* %in2
85    %r2 = load <4 x double> addrspace(1)* %in3
86    %r3 = tail call <4 x double> @llvm.fma.v4f64(<4 x double> %r0, <4 x double> %r1, <4 x double> %r2)
87    store <4 x double> %r3, <4 x double> addrspace(1)* %out
88    ret void
89 }