[X86] Add test showing failure to concat fma nodes due to the constant being hidden (#174969)

By the time the maxps nodes have been lowered, the v4f32 constant splats
have been hidden behind a extract_subvector from the v8f32 constant
splat
This commit is contained in:
Simon Pilgrim 2026-01-08 13:25:42 +00:00 committed by GitHub
parent 56e8aa658a
commit 476ad9f03c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -279,6 +279,42 @@ define <8 x double> @concat_fma_fmsub_v8f64_v4f64_constant_repeatedop_commute(<4
ret <8 x double> %r
}
; FIXME: FMA can't be concatenated until after max intrinsics have lowered, but then the v4f32 broadcasted constant is hidden behind an EXTRACT_SUBVECTOR
define <8 x float> @concat_fma_v8f32_v4f32_late_concat(<4 x float> %x, <4 x float> %y, <8 x float> %z) {
; FMA4-LABEL: concat_fma_v8f32_v4f32_late_concat:
; FMA4: # %bb.0:
; FMA4-NEXT: vmovaps {{.*#+}} ymm3 = [2.0E+0,2.0E+0,2.0E+0,2.0E+0,2.0E+0,2.0E+0,2.0E+0,2.0E+0]
; FMA4-NEXT: vfmaddps {{.*#+}} xmm0 = (xmm0 * xmm0) + xmm3
; FMA4-NEXT: vfmaddps {{.*#+}} xmm1 = (xmm1 * xmm1) + xmm3
; FMA4-NEXT: vmaxps %ymm3, %ymm2, %ymm2
; FMA4-NEXT: vbroadcastf128 {{.*#+}} ymm3 = [2.0E+0,2.0E+0,2.0E+0,2.0E+0,2.0E+0,2.0E+0,2.0E+0,2.0E+0]
; FMA4-NEXT: # ymm3 = mem[0,1,0,1]
; FMA4-NEXT: vinsertf128 $1, %xmm1, %ymm0, %ymm0
; FMA4-NEXT: vmaxps %ymm3, %ymm0, %ymm0
; FMA4-NEXT: vaddps %ymm2, %ymm0, %ymm0
; FMA4-NEXT: retq
;
; FMA3-LABEL: concat_fma_v8f32_v4f32_late_concat:
; FMA3: # %bb.0:
; FMA3-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
; FMA3-NEXT: vbroadcastss {{.*#+}} ymm3 = [2.0E+0,2.0E+0,2.0E+0,2.0E+0,2.0E+0,2.0E+0,2.0E+0,2.0E+0]
; FMA3-NEXT: vfmadd213ps {{.*#+}} xmm0 = (xmm0 * xmm0) + xmm3
; FMA3-NEXT: vfmadd213ps {{.*#+}} xmm1 = (xmm1 * xmm1) + xmm3
; FMA3-NEXT: vmaxps %ymm3, %ymm2, %ymm2
; FMA3-NEXT: vinsertf128 $1, %xmm1, %ymm0, %ymm0
; FMA3-NEXT: vmaxps %ymm3, %ymm0, %ymm0
; FMA3-NEXT: vaddps %ymm2, %ymm0, %ymm0
; FMA3-NEXT: retq
%xx = call <4 x float> @llvm.fma.v4f32(<4 x float> %x, <4 x float> %x, <4 x float> splat (float 2.000000e+00))
%yy = call <4 x float> @llvm.fma.v4f32(<4 x float> %y, <4 x float> %y, <4 x float> splat (float 2.000000e+00))
%lo = call <4 x float> @llvm.x86.sse.max.ps(<4 x float> %xx, <4 x float> splat (float 2.000000e+00))
%hi = call <4 x float> @llvm.x86.sse.max.ps(<4 x float> %yy, <4 x float> splat (float 2.000000e+00))
%rhs = call <8 x float> @llvm.x86.avx.max.ps.256(<8 x float> %z, <8 x float> splat (float 2.000000e+00))
%lhs = shufflevector <4 x float> %lo, <4 x float> %hi, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
%add = fadd <8 x float> %lhs, %rhs
ret <8 x float> %add
}
; negative - too many operands to concat
define <8 x float> @concat_fmadd_v8f32_v4f32(<4 x float> %a0, <4 x float> %a1, <4 x float> %b0, <4 x float> %b1, <4 x float> %c0, <4 x float> %c1) {
; FMA4-LABEL: concat_fmadd_v8f32_v4f32: