Skip to content

Commit 8854b27

Browse files
committed
[x86] update fma test with deprecated intrinsics; NFC
All of the CHECK lines should be identical to before, but without any of the x86-specific calls that were replaced with generic FMA long ago. The file still has value because it shows a miscompile as demonstrated in D90901, but we probably need to add tests with FMF to make that explicit without losing coverage.
1 parent 4158746 commit 8854b27

File tree

1 file changed

+52
-61
lines changed

1 file changed

+52
-61
lines changed

llvm/test/CodeGen/X86/avx2-fma-fneg-combine.ll

Lines changed: 52 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,158 +2,149 @@
22
; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+avx2,+fma | FileCheck %s --check-prefix=X32
33
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2,+fma | FileCheck %s --check-prefix=X64
44

5+
declare <8 x float> @llvm.fma.v8f32(<8 x float>, <8 x float>, <8 x float>)
6+
declare <4 x float> @llvm.fma.v4f32(<4 x float>, <4 x float>, <4 x float>)
7+
declare float @llvm.fma.f32(float, float, float)
8+
declare <2 x double> @llvm.fma.v2f64(<2 x double>, <2 x double>, <2 x double>)
9+
510
; This test checks combinations of FNEG and FMA intrinsics
611

712
define <8 x float> @test1(<8 x float> %a, <8 x float> %b, <8 x float> %c) {
813
; X32-LABEL: test1:
9-
; X32: # %bb.0: # %entry
14+
; X32: # %bb.0:
1015
; X32-NEXT: vfmsub213ps {{.*#+}} ymm0 = (ymm1 * ymm0) - ymm2
1116
; X32-NEXT: retl
1217
;
1318
; X64-LABEL: test1:
14-
; X64: # %bb.0: # %entry
19+
; X64: # %bb.0:
1520
; X64-NEXT: vfmsub213ps {{.*#+}} ymm0 = (ymm1 * ymm0) - ymm2
1621
; X64-NEXT: retq
17-
entry:
18-
%sub.i = fsub <8 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %c
19-
%0 = tail call <8 x float> @llvm.x86.fma.vfmadd.ps.256(<8 x float> %a, <8 x float> %b, <8 x float> %sub.i) #2
20-
ret <8 x float> %0
22+
%sub.i = fsub <8 x float> <float -0.0, float -0.0, float -0.0, float -0.0, float -0.0, float -0.0, float -0.0, float -0.0>, %c
23+
%r = tail call <8 x float> @llvm.fma.v8f32(<8 x float> %a, <8 x float> %b, <8 x float> %sub.i) #2
24+
ret <8 x float> %r
2125
}
2226

23-
declare <8 x float> @llvm.x86.fma.vfmadd.ps.256(<8 x float>, <8 x float>, <8 x float>)
24-
2527
define <4 x float> @test2(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
2628
; X32-LABEL: test2:
27-
; X32: # %bb.0: # %entry
29+
; X32: # %bb.0:
2830
; X32-NEXT: vfnmsub213ps {{.*#+}} xmm0 = -(xmm1 * xmm0) - xmm2
2931
; X32-NEXT: retl
3032
;
3133
; X64-LABEL: test2:
32-
; X64: # %bb.0: # %entry
34+
; X64: # %bb.0:
3335
; X64-NEXT: vfnmsub213ps {{.*#+}} xmm0 = -(xmm1 * xmm0) - xmm2
3436
; X64-NEXT: retq
35-
entry:
36-
%0 = tail call <4 x float> @llvm.x86.fma.vfmadd.ps(<4 x float> %a, <4 x float> %b, <4 x float> %c) #2
37-
%sub.i = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %0
37+
%t0 = tail call <4 x float> @llvm.fma.v4f32(<4 x float> %a, <4 x float> %b, <4 x float> %c) #2
38+
%sub.i = fsub <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>, %t0
3839
ret <4 x float> %sub.i
3940
}
4041

41-
declare <4 x float> @llvm.x86.fma.vfmadd.ps(<4 x float> %a, <4 x float> %b, <4 x float> %c)
42-
4342
define <4 x float> @test3(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
4443
; X32-LABEL: test3:
45-
; X32: # %bb.0: # %entry
44+
; X32: # %bb.0:
4645
; X32-NEXT: vfnmadd213ss {{.*#+}} xmm0 = -(xmm1 * xmm0) + xmm2
4746
; X32-NEXT: vbroadcastss {{.*#+}} xmm1 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
4847
; X32-NEXT: vxorps %xmm1, %xmm0, %xmm0
4948
; X32-NEXT: retl
5049
;
5150
; X64-LABEL: test3:
52-
; X64: # %bb.0: # %entry
51+
; X64: # %bb.0:
5352
; X64-NEXT: vfnmadd213ss {{.*#+}} xmm0 = -(xmm1 * xmm0) + xmm2
5453
; X64-NEXT: vbroadcastss {{.*#+}} xmm1 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
5554
; X64-NEXT: vxorps %xmm1, %xmm0, %xmm0
5655
; X64-NEXT: retq
57-
entry:
58-
%0 = tail call <4 x float> @llvm.x86.fma.vfnmadd.ss(<4 x float> %a, <4 x float> %b, <4 x float> %c) #2
59-
%sub.i = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %0
56+
%a0 = extractelement <4 x float> %a, i64 0
57+
%b0 = extractelement <4 x float> %b, i64 0
58+
%c0 = extractelement <4 x float> %c, i64 0
59+
%negb0 = fneg float %b0
60+
%t0 = tail call float @llvm.fma.f32(float %a0, float %negb0, float %c0) #2
61+
%i = insertelement <4 x float> %a, float %t0, i64 0
62+
%sub.i = fsub <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>, %i
6063
ret <4 x float> %sub.i
6164
}
6265

63-
declare <4 x float> @llvm.x86.fma.vfnmadd.ss(<4 x float> %a, <4 x float> %b, <4 x float> %c)
64-
6566
define <8 x float> @test4(<8 x float> %a, <8 x float> %b, <8 x float> %c) {
6667
; X32-LABEL: test4:
67-
; X32: # %bb.0: # %entry
68+
; X32: # %bb.0:
6869
; X32-NEXT: vfnmadd213ps {{.*#+}} ymm0 = -(ymm1 * ymm0) + ymm2
6970
; X32-NEXT: retl
7071
;
7172
; X64-LABEL: test4:
72-
; X64: # %bb.0: # %entry
73+
; X64: # %bb.0:
7374
; X64-NEXT: vfnmadd213ps {{.*#+}} ymm0 = -(ymm1 * ymm0) + ymm2
7475
; X64-NEXT: retq
75-
entry:
76-
%0 = tail call <8 x float> @llvm.x86.fma.vfmsub.ps.256(<8 x float> %a, <8 x float> %b, <8 x float> %c) #2
77-
%sub.i = fsub <8 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %0
76+
%negc = fneg <8 x float> %c
77+
%t0 = tail call <8 x float> @llvm.fma.v8f32(<8 x float> %a, <8 x float> %b, <8 x float> %negc) #2
78+
%sub.i = fsub <8 x float> <float -0.0, float -0.0, float -0.0, float -0.0, float -0.0, float -0.0, float -0.0, float -0.0>, %t0
7879
ret <8 x float> %sub.i
7980
}
8081

8182
define <8 x float> @test5(<8 x float> %a, <8 x float> %b, <8 x float> %c) {
8283
; X32-LABEL: test5:
83-
; X32: # %bb.0: # %entry
84+
; X32: # %bb.0:
8485
; X32-NEXT: vfmadd213ps {{.*#+}} ymm0 = (ymm1 * ymm0) + ymm2
8586
; X32-NEXT: retl
8687
;
8788
; X64-LABEL: test5:
88-
; X64: # %bb.0: # %entry
89+
; X64: # %bb.0:
8990
; X64-NEXT: vfmadd213ps {{.*#+}} ymm0 = (ymm1 * ymm0) + ymm2
9091
; X64-NEXT: retq
91-
entry:
92-
%sub.c = fsub <8 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %c
93-
%0 = tail call <8 x float> @llvm.x86.fma.vfmsub.ps.256(<8 x float> %a, <8 x float> %b, <8 x float> %sub.c) #2
94-
ret <8 x float> %0
92+
%sub.c = fsub <8 x float> <float -0.0, float -0.0, float -0.0, float -0.0, float -0.0, float -0.0, float -0.0, float -0.0>, %c
93+
%negsubc = fneg <8 x float> %sub.c
94+
%t0 = tail call <8 x float> @llvm.fma.v8f32(<8 x float> %a, <8 x float> %b, <8 x float> %negsubc) #2
95+
ret <8 x float> %t0
9596
}
9697

97-
declare <8 x float> @llvm.x86.fma.vfmsub.ps.256(<8 x float>, <8 x float>, <8 x float>)
98-
99-
10098
define <2 x double> @test6(<2 x double> %a, <2 x double> %b, <2 x double> %c) {
10199
; X32-LABEL: test6:
102-
; X32: # %bb.0: # %entry
100+
; X32: # %bb.0:
103101
; X32-NEXT: vfnmsub213pd {{.*#+}} xmm0 = -(xmm1 * xmm0) - xmm2
104102
; X32-NEXT: retl
105103
;
106104
; X64-LABEL: test6:
107-
; X64: # %bb.0: # %entry
105+
; X64: # %bb.0:
108106
; X64-NEXT: vfnmsub213pd {{.*#+}} xmm0 = -(xmm1 * xmm0) - xmm2
109107
; X64-NEXT: retq
110-
entry:
111-
%0 = tail call <2 x double> @llvm.x86.fma.vfmadd.pd(<2 x double> %a, <2 x double> %b, <2 x double> %c) #2
112-
%sub.i = fsub <2 x double> <double -0.000000e+00, double -0.000000e+00>, %0
108+
%t0 = tail call <2 x double> @llvm.fma.v2f64(<2 x double> %a, <2 x double> %b, <2 x double> %c) #2
109+
%sub.i = fsub <2 x double> <double -0.0, double -0.0>, %t0
113110
ret <2 x double> %sub.i
114111
}
115112

116-
declare <2 x double> @llvm.x86.fma.vfmadd.pd(<2 x double> %a, <2 x double> %b, <2 x double> %c)
117-
118113
define <8 x float> @test7(float %a, <8 x float> %b, <8 x float> %c) {
119114
; X32-LABEL: test7:
120-
; X32: # %bb.0: # %entry
115+
; X32: # %bb.0:
121116
; X32-NEXT: vbroadcastss {{[0-9]+}}(%esp), %ymm2
122117
; X32-NEXT: vfnmadd213ps {{.*#+}} ymm0 = -(ymm2 * ymm0) + ymm1
123118
; X32-NEXT: retl
124119
;
125120
; X64-LABEL: test7:
126-
; X64: # %bb.0: # %entry
121+
; X64: # %bb.0:
127122
; X64-NEXT: vbroadcastss %xmm0, %ymm0
128123
; X64-NEXT: vfnmadd213ps {{.*#+}} ymm0 = -(ymm1 * ymm0) + ymm2
129124
; X64-NEXT: retq
130-
entry:
131-
%0 = insertelement <8 x float> undef, float %a, i32 0
132-
%1 = fsub <8 x float> <float -0.000000e+00, float undef, float undef, float undef, float undef, float undef, float undef, float undef>, %0
133-
%2 = shufflevector <8 x float> %1, <8 x float> undef, <8 x i32> zeroinitializer
134-
%3 = tail call <8 x float> @llvm.fma.v8f32(<8 x float> %2, <8 x float> %b, <8 x float> %c)
135-
ret <8 x float> %3
125+
%t0 = insertelement <8 x float> undef, float %a, i32 0
126+
%t1 = fsub <8 x float> <float -0.0, float undef, float undef, float undef, float undef, float undef, float undef, float undef>, %t0
127+
%t2 = shufflevector <8 x float> %t1, <8 x float> undef, <8 x i32> zeroinitializer
128+
%t3 = tail call <8 x float> @llvm.fma.v8f32(<8 x float> %t2, <8 x float> %b, <8 x float> %c)
129+
ret <8 x float> %t3
136130

137131
}
138132

139133
define <8 x float> @test8(float %a, <8 x float> %b, <8 x float> %c) {
140134
; X32-LABEL: test8:
141-
; X32: # %bb.0: # %entry
135+
; X32: # %bb.0:
142136
; X32-NEXT: vbroadcastss {{[0-9]+}}(%esp), %ymm2
143137
; X32-NEXT: vfnmadd213ps {{.*#+}} ymm0 = -(ymm2 * ymm0) + ymm1
144138
; X32-NEXT: retl
145139
;
146140
; X64-LABEL: test8:
147-
; X64: # %bb.0: # %entry
141+
; X64: # %bb.0:
148142
; X64-NEXT: vbroadcastss %xmm0, %ymm0
149143
; X64-NEXT: vfnmadd213ps {{.*#+}} ymm0 = -(ymm1 * ymm0) + ymm2
150144
; X64-NEXT: retq
151-
entry:
152-
%0 = fsub float -0.0, %a
153-
%1 = insertelement <8 x float> undef, float %0, i32 0
154-
%2 = shufflevector <8 x float> %1, <8 x float> undef, <8 x i32> zeroinitializer
155-
%3 = tail call <8 x float> @llvm.fma.v8f32(<8 x float> %2, <8 x float> %b, <8 x float> %c)
156-
ret <8 x float> %3
145+
%t0 = fsub float -0.0, %a
146+
%t1 = insertelement <8 x float> undef, float %t0, i32 0
147+
%t2 = shufflevector <8 x float> %t1, <8 x float> undef, <8 x i32> zeroinitializer
148+
%t3 = tail call <8 x float> @llvm.fma.v8f32(<8 x float> %t2, <8 x float> %b, <8 x float> %c)
149+
ret <8 x float> %t3
157150
}
158-
159-
declare <8 x float> @llvm.fma.v8f32(<8 x float> %a, <8 x float> %b, <8 x float> %c)

0 commit comments

Comments
 (0)