1 // REQUIRES: x86-registered-target
2 // UNSUPPORTED: target={{.*}}-zos{{.*}}
3 // RUN: %clang -S -emit-llvm -fenable-matrix -ffp-model=fast %s -o - \
4 // RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-FAST
6 // RUN: %clang -S -emit-llvm -fenable-matrix -ffp-model=aggressive %s -o - \
7 // RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-AGGRESSIVE
9 // RUN: %clang -S -emit-llvm -fenable-matrix -ffp-model=precise %s -o - \
10 // RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-PRECISE
12 // RUN: %clang -S -emit-llvm -fenable-matrix -ffp-model=strict %s -o - \
13 // RUN: -target x86_64 | FileCheck %s --check-prefixes=CHECK,CHECK-STRICT
15 // RUN: %clang -S -emit-llvm -fenable-matrix -ffp-model=strict -ffast-math \
16 // RUN: -target x86_64 %s -o - | FileCheck %s \
17 // RUN: --check-prefixes CHECK,CHECK-STRICT-FAST
19 // RUN: %clang -S -emit-llvm -fenable-matrix -ffp-model=precise -ffast-math \
20 // RUN: %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-FAST1
22 float mymuladd(float x
, float y
, float z
) {
23 // CHECK: define{{.*}} float @mymuladd
26 // CHECK-AGGRESSIVE: fmul fast float
27 // CHECK-AGGRESSIVE: load float, ptr
28 // CHECK-AGGRESSIVE: fadd fast float
30 // CHECK-FAST: fmul reassoc nsz arcp contract afn float
31 // CHECK-FAST: load float, ptr
32 // CHECK-FAST: fadd reassoc nsz arcp contract afn float
34 // CHECK-PRECISE: load float, ptr
35 // CHECK-PRECISE: load float, ptr
36 // CHECK-PRECISE: load float, ptr
37 // CHECK-PRECISE: call float @llvm.fmuladd.f32(float {{.*}}, float {{.*}}, float {{.*}})
39 // CHECK-STRICT: load float, ptr
40 // CHECK-STRICT: load float, ptr
41 // CHECK-STRICT: call float @llvm.experimental.constrained.fmul.f32(float {{.*}}, float {{.*}}, {{.*}})
42 // CHECK-STRICT: load float, ptr
43 // CHECK-STRICT: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, float {{.*}}, {{.*}})
45 // CHECK-STRICT-FAST: load float, ptr
46 // CHECK-STRICT-FAST: load float, ptr
47 // CHECK-STRICT-FAST: fmul fast float {{.*}}, {{.*}}
48 // CHECK-STRICT-FAST: load float, ptr
49 // CHECK-STRICT-FAST: fadd fast float {{.*}}, {{.*}}
51 // CHECK-FAST1: load float, ptr
52 // CHECK-FAST1: load float, ptr
53 // CHECK-FAST1: fmul fast float {{.*}}, {{.*}}
54 // CHECK-FAST1: load float, ptr {{.*}}
55 // CHECK-FAST1: fadd fast float {{.*}}, {{.*}}
58 typedef float __attribute__((ext_vector_type(2))) v2f
;
60 void my_vec_muladd(v2f x
, float y
, v2f z
, v2f
*res
) {
61 // CHECK: define{{.*}}@my_vec_muladd
64 // CHECK-AGGRESSIVE: fmul fast <2 x float>
65 // CHECK-AGGRESSIVE: load <2 x float>, ptr
66 // CHECK-AGGRESSIVE: fadd fast <2 x float>
68 // CHECK-FAST: fmul reassoc nsz arcp contract afn <2 x float>
69 // CHECK-FAST: load <2 x float>, ptr
70 // CHECK-FAST: fadd reassoc nsz arcp contract afn <2 x float>
72 // CHECK-PRECISE: load <2 x float>, ptr
73 // CHECK-PRECISE: load float, ptr
74 // CHECK-PRECISE: load <2 x float>, ptr
75 // CHECK-PRECISE: call <2 x float> @llvm.fmuladd.v2f32(<2 x float> {{.*}}, <2 x float> {{.*}}, <2 x float> {{.*}})
77 // CHECK-STRICT: load <2 x float>, ptr
78 // CHECK-STRICT: load float, ptr
79 // CHECK-STRICT: call <2 x float> @llvm.experimental.constrained.fmul.v2f32(<2 x float> {{.*}}, <2 x float> {{.*}}, {{.*}})
80 // CHECK-STRICT: load <2 x float>, ptr
81 // CHECK-STRICT: call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> {{.*}}, <2 x float> {{.*}}, {{.*}})
83 // CHECK-STRICT-FAST: load <2 x float>, ptr
84 // CHECK-STRICT-FAST: load float, ptr
85 // CHECK-STRICT-FAST: fmul fast <2 x float> {{.*}}, {{.*}}
86 // CHECK-STRICT-FAST: load <2 x float>, ptr
87 // CHECK-STRICT-FAST: fadd fast <2 x float> {{.*}}, {{.*}}
89 // CHECK-FAST1: load <2 x float>, ptr
90 // CHECK-FAST1: load float, ptr
91 // CHECK-FAST1: fmul fast <2 x float> {{.*}}, {{.*}}
92 // CHECK-FAST1: load <2 x float>, ptr {{.*}}
93 // CHECK-FAST1: fadd fast <2 x float> {{.*}}, {{.*}}
96 typedef float __attribute__((matrix_type(2, 1))) m21f
;
98 void my_m21_muladd(m21f x
, float y
, m21f z
, m21f
*res
) {
99 // CHECK: define{{.*}}@my_m21_muladd
102 // CHECK-AGGRESSIVE: fmul fast <2 x float>
103 // CHECK-AGGRESSIVE: load <2 x float>, ptr
104 // CHECK-AGGRESSIVE: fadd fast <2 x float>
106 // CHECK-FAST: fmul reassoc nsz arcp contract afn <2 x float>
107 // CHECK-FAST: load <2 x float>, ptr
108 // CHECK-FAST: fadd reassoc nsz arcp contract afn <2 x float>
110 // CHECK-PRECISE: load <2 x float>, ptr
111 // CHECK-PRECISE: load float, ptr
112 // CHECK-PRECISE: load <2 x float>, ptr
113 // CHECK-PRECISE: call <2 x float> @llvm.fmuladd.v2f32(<2 x float> {{.*}}, <2 x float> {{.*}}, <2 x float> {{.*}})
115 // CHECK-STRICT: load <2 x float>, ptr
116 // CHECK-STRICT: load float, ptr
117 // CHECK-STRICT: call <2 x float> @llvm.experimental.constrained.fmul.v2f32(<2 x float> {{.*}}, <2 x float> {{.*}}, {{.*}})
118 // CHECK-STRICT: load <2 x float>, ptr
119 // CHECK-STRICT: call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> {{.*}}, <2 x float> {{.*}}, {{.*}})
121 // CHECK-STRICT-FAST: load <2 x float>, ptr
122 // CHECK-STRICT-FAST: load float, ptr
123 // CHECK-STRICT-FAST: fmul fast <2 x float> {{.*}}, {{.*}}
124 // CHECK-STRICT-FAST: load <2 x float>, ptr
125 // CHECK-STRICT-FAST: fadd fast <2 x float> {{.*}}, {{.*}}
127 // CHECK-FAST1: load <2 x float>, ptr
128 // CHECK-FAST1: load float, ptr
129 // CHECK-FAST1: fmul fast <2 x float> {{.*}}, {{.*}}
130 // CHECK-FAST1: load <2 x float>, ptr {{.*}}
131 // CHECK-FAST1: fadd fast <2 x float> {{.*}}, {{.*}}
134 typedef float __attribute__((matrix_type(2, 2))) m22f
;
136 void my_m22_muladd(m22f x
, float y
, m22f z
, m22f
*res
) {
137 // CHECK: define{{.*}}@my_m22_muladd
140 // CHECK-AGGRESSIVE: fmul fast <4 x float>
141 // CHECK-AGGRESSIVE: load <4 x float>, ptr
142 // CHECK-AGGRESSIVE: fadd fast <4 x float>
144 // CHECK-FAST: fmul reassoc nsz arcp contract afn <4 x float>
145 // CHECK-FAST: load <4 x float>, ptr
146 // CHECK-FAST: fadd reassoc nsz arcp contract afn <4 x float>
148 // CHECK-PRECISE: load <4 x float>, ptr
149 // CHECK-PRECISE: load float, ptr
150 // CHECK-PRECISE: load <4 x float>, ptr
151 // CHECK-PRECISE: call <4 x float> @llvm.fmuladd.v4f32(<4 x float> {{.*}}, <4 x float> {{.*}}, <4 x float> {{.*}})
153 // CHECK-STRICT: load <4 x float>, ptr
154 // CHECK-STRICT: load float, ptr
155 // CHECK-STRICT: call <4 x float> @llvm.experimental.constrained.fmul.v4f32(<4 x float> {{.*}}, <4 x float> {{.*}}, {{.*}})
156 // CHECK-STRICT: load <4 x float>, ptr
157 // CHECK-STRICT: call <4 x float> @llvm.experimental.constrained.fadd.v4f32(<4 x float> {{.*}}, <4 x float> {{.*}}, {{.*}})
159 // CHECK-STRICT-FAST: load <4 x float>, ptr
160 // CHECK-STRICT-FAST: load float, ptr
161 // CHECK-STRICT-FAST: fmul fast <4 x float> {{.*}}, {{.*}}
162 // CHECK-STRICT-FAST: load <4 x float>, ptr
163 // CHECK-STRICT-FAST: fadd fast <4 x float> {{.*}}, {{.*}}
165 // CHECK-FAST1: load <4 x float>, ptr
166 // CHECK-FAST1: load float, ptr
167 // CHECK-FAST1: fmul fast <4 x float> {{.*}}, {{.*}}
168 // CHECK-FAST1: load <4 x float>, ptr {{.*}}
169 // CHECK-FAST1: fadd fast <4 x float> {{.*}}, {{.*}}