[llvm] 476ad9f - [X86] Add test showing failure to concat fma nodes due to the constant being hidden (#174969)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 8 05:25:47 PST 2026
Author: Simon Pilgrim
Date: 2026-01-08T13:25:42Z
New Revision: 476ad9f03cdf43cb801eb478273b5fa301bf006a
URL: https://github.com/llvm/llvm-project/commit/476ad9f03cdf43cb801eb478273b5fa301bf006a
DIFF: https://github.com/llvm/llvm-project/commit/476ad9f03cdf43cb801eb478273b5fa301bf006a.diff
LOG: [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
Added:
Modified:
llvm/test/CodeGen/X86/combine-fma-concat.ll
Removed:
################################################################################
diff --git a/llvm/test/CodeGen/X86/combine-fma-concat.ll b/llvm/test/CodeGen/X86/combine-fma-concat.ll
index 792b7ff1b7d74..fe66918b66568 100644
--- a/llvm/test/CodeGen/X86/combine-fma-concat.ll
+++ b/llvm/test/CodeGen/X86/combine-fma-concat.ll
@@ -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:
More information about the llvm-commits
mailing list