[PATCH] D89527: [DAGCombiner] Tighten reasscociation of visitFMA
Qiu Chaofan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 18 23:42:16 PDT 2020
qiucf updated this revision to Diff 298934.
qiucf marked an inline comment as done.
qiucf added a comment.
Add another test about preventing combined into `(fmul x, c1+c2)`. (test was not pre-committed, diff is for review)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D89527/new/
https://reviews.llvm.org/D89527
Files:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/PowerPC/fma-combine.ll
llvm/test/CodeGen/X86/fma-scalar-combine.ll
Index: llvm/test/CodeGen/X86/fma-scalar-combine.ll
===================================================================
--- llvm/test/CodeGen/X86/fma-scalar-combine.ll
+++ llvm/test/CodeGen/X86/fma-scalar-combine.ll
@@ -547,8 +547,11 @@
define float @fma_const_fmul(float %x) {
; CHECK-LABEL: fma_const_fmul:
; CHECK: # %bb.0:
-; CHECK-NEXT: vmulss {{.*}}(%rip), %xmm0, %xmm0 # EVEX TO VEX Compression encoding: [0xc5,0xfa,0x59,0x05,A,A,A,A]
+; CHECK-NEXT: vmulss {{.*}}(%rip), %xmm0, %xmm1 # EVEX TO VEX Compression encoding: [0xc5,0xfa,0x59,0x0d,A,A,A,A]
; CHECK-NEXT: # fixup A - offset: 4, value: {{\.LCPI.*}}-4, kind: reloc_riprel_4byte
+; CHECK-NEXT: vfmadd132ss {{.*}}(%rip), %xmm1, %xmm0 # EVEX TO VEX Compression encoding: [0xc4,0xe2,0x71,0x99,0x05,A,A,A,A]
+; CHECK-NEXT: # fixup A - offset: 5, value: {{\.LCPI.*}}-4, kind: reloc_riprel_4byte
+; CHECK-NEXT: # xmm0 = (xmm0 * mem) + xmm1
; CHECK-NEXT: retq # encoding: [0xc3]
%mul1 = fmul contract float %x, 10.0
%mul2 = fmul contract float %x, 11.0
Index: llvm/test/CodeGen/PowerPC/fma-combine.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/fma-combine.ll
+++ llvm/test/CodeGen/PowerPC/fma-combine.ll
@@ -333,8 +333,11 @@
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: addis 3, 2, .LCPI9_0 at toc@ha
; CHECK-NEXT: lfd 0, .LCPI9_0 at toc@l(3)
-; CHECK-NEXT: xsmaddadp 2, 1, 0
+; CHECK-NEXT: addis 3, 2, .LCPI9_1 at toc@ha
+; CHECK-NEXT: lfd 3, .LCPI9_1 at toc@l(3)
+; CHECK-NEXT: xsmuldp 0, 1, 0
; CHECK-NEXT: fmr 1, 2
+; CHECK-NEXT: xsmaddadp 1, 0, 3
; CHECK-NEXT: blr
entry:
%0 = fmul double %a, 1.1
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -13212,7 +13212,8 @@
SelectionDAG::FlagInserter FlagsInserter(DAG, N);
// FMA nodes have flags that propagate to the created nodes.
- bool UnsafeFPMath = Options.UnsafeFPMath || isContractable(N);
+ bool UnsafeFPMath =
+ Options.UnsafeFPMath || N->getFlags().hasAllowReassociation();
// Constant fold FMA.
if (isa<ConstantFPSDNode>(N0) &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89527.298934.patch
Type: text/x-patch
Size: 2262 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201019/f945e9a7/attachment.bin>
More information about the llvm-commits
mailing list