[llvm] r327659 - [X86] Add test case showing bad fmsubadd creation due to bad commuting.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 15 13:30:51 PDT 2018


Author: ctopper
Date: Thu Mar 15 13:30:51 2018
New Revision: 327659

URL: http://llvm.org/viewvc/llvm-project?rev=327659&view=rev
Log:
[X86] Add test case showing bad fmsubadd creation due to bad commuting.

The code that creates fmsubadd from shuffle vector has some code to allow commuting the operands of the fadd node. This code was originally created when we only recognized fmaddsub. When fmsubadd support was added this code was not updated and is now commuting the fsub operands instead.

Modified:
    llvm/trunk/test/CodeGen/X86/fmsubadd-combine.ll

Modified: llvm/trunk/test/CodeGen/X86/fmsubadd-combine.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fmsubadd-combine.ll?rev=327659&r1=327658&r2=327659&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fmsubadd-combine.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fmsubadd-combine.ll Thu Mar 15 13:30:51 2018
@@ -132,4 +132,23 @@ entry:
   ret <16 x float> %subadd
 }
 
+; This should not be matched to fmsubadd because the mul is on the wrong side of the fsub.
+define <2 x double> @mul_subadd_bad_commute(<2 x double> %A, <2 x double> %B, <2 x double> %C) #0 {
+; FMA3-LABEL: mul_subadd_bad_commute:
+; FMA3:       # %bb.0: # %entry
+; FMA3-NEXT:    vfmsubadd213pd {{.*#+}} xmm0 = (xmm1 * xmm0) -/+ xmm2
+; FMA3-NEXT:    retq
+;
+; FMA4-LABEL: mul_subadd_bad_commute:
+; FMA4:       # %bb.0: # %entry
+; FMA4-NEXT:    vfmsubaddpd %xmm2, %xmm1, %xmm0, %xmm0
+; FMA4-NEXT:    retq
+entry:
+  %AB = fmul <2 x double> %A, %B
+  %Sub = fsub <2 x double> %C, %AB
+  %Add = fadd <2 x double> %AB, %C
+  %subadd = shufflevector <2 x double> %Add, <2 x double> %Sub, <2 x i32> <i32 0, i32 3>
+  ret <2 x double> %subadd
+}
+
 attributes #0 = { nounwind "unsafe-fp-math"="true" }




More information about the llvm-commits mailing list