[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.

llvm-svn: 327659
This commit is contained in:
Craig Topper 2018-03-15 20:30:51 +00:00
parent a46b8a7677
commit 46502fa2ef
1 changed files with 19 additions and 0 deletions

View File

@ -132,4 +132,23 @@ entry:
ret <16 x float> %subadd 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" } attributes #0 = { nounwind "unsafe-fp-math"="true" }