[PATCH] D147017: [X86] Add a fneg test for fma with a splat constant vector

Evgenii Kudriashov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 27 19:03:48 PDT 2023


e-kud created this revision.
Herald added a subscriber: pengfei.
Herald added a project: All.
e-kud requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147017

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


Index: llvm/test/CodeGen/X86/avx2-fma-fneg-combine.ll
===================================================================
--- llvm/test/CodeGen/X86/avx2-fma-fneg-combine.ll
+++ llvm/test/CodeGen/X86/avx2-fma-fneg-combine.ll
@@ -6,6 +6,7 @@
 declare <4 x float> @llvm.fma.v4f32(<4 x float>, <4 x float>, <4 x float>)
 declare float @llvm.fma.f32(float, float, float)
 declare <2 x double> @llvm.fma.v2f64(<2 x double>, <2 x double>, <2 x double>)
+declare <4 x double> @llvm.fma.v4f64(<4 x double>, <4 x double>, <4 x double>)
 
 ; This test checks combinations of FNEG and FMA intrinsics
 
@@ -148,3 +149,27 @@
   %t3 = tail call nsz <8 x float> @llvm.fma.v8f32(<8 x float> %t2, <8 x float> %b, <8 x float> %c)
   ret <8 x float> %t3
 }
+
+define <4 x double> @test9(<4 x double> %a, <4 x double> %b) {
+; X32-LABEL: test9:
+; X32:       # %bb.0:
+; X32-NEXT:    vbroadcastsd {{.*#+}} ymm2 = [-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1]
+; X32-NEXT:    vfmadd213pd {{.*#+}} ymm2 = (ymm0 * ymm2) + ymm1
+; X32-NEXT:    vbroadcastsd {{.*#+}} ymm3 = [5.0E-1,5.0E-1,5.0E-1,5.0E-1]
+; X32-NEXT:    vfmadd213pd {{.*#+}} ymm3 = (ymm0 * ymm3) + ymm1
+; X32-NEXT:    vaddpd %ymm3, %ymm2, %ymm0
+; X32-NEXT:    retl
+;
+; X64-LABEL: test9:
+; X64:       # %bb.0:
+; X64-NEXT:    vbroadcastsd {{.*#+}} ymm2 = [-5.0E-1,-5.0E-1,-5.0E-1,-5.0E-1]
+; X64-NEXT:    vfmadd213pd {{.*#+}} ymm2 = (ymm0 * ymm2) + ymm1
+; X64-NEXT:    vbroadcastsd {{.*#+}} ymm3 = [5.0E-1,5.0E-1,5.0E-1,5.0E-1]
+; X64-NEXT:    vfmadd213pd {{.*#+}} ymm3 = (ymm0 * ymm3) + ymm1
+; X64-NEXT:    vaddpd %ymm3, %ymm2, %ymm0
+; X64-NEXT:    retq
+  %t0 = tail call <4 x double> @llvm.fma.v4f64(<4 x double> %a, <4 x double> <double -5.000000e-01, double undef, double -5.000000e-01, double -5.000000e-01>, <4 x double> %b)
+  %t1 = tail call <4 x double> @llvm.fma.v4f64(<4 x double> %a, <4 x double> <double 5.000000e-01, double undef, double 5.000000e-01, double 5.000000e-01>, <4 x double> %b)
+  %t2 = fadd <4 x double> %t0, %t1
+  ret <4 x double> %t2
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147017.508867.patch
Type: text/x-patch
Size: 2004 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230328/e4d06302/attachment.bin>


More information about the llvm-commits mailing list