[PATCH] D90901: [DAGCombiner] Don't fold ((fma (fneg X), Y, (fneg Z)) to fneg (fma X, Y, Z))
Jim Lin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 6 01:21:23 PST 2020
Jim updated this revision to Diff 303364.
Jim added a comment.
Herald added a subscriber: nemanjai.
Update testcase.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D90901/new/
https://reviews.llvm.org/D90901
Files:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/PowerPC/fma-combine.ll
Index: llvm/test/CodeGen/PowerPC/fma-combine.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/fma-combine.ll
+++ llvm/test/CodeGen/PowerPC/fma-combine.ll
@@ -171,16 +171,18 @@
; CHECK: # %bb.0:
; CHECK-NEXT: addis 3, 2, .LCPI4_0 at toc@ha
; CHECK-NEXT: addis 4, 2, .LCPI4_1 at toc@ha
-; CHECK-NEXT: lfs 0, .LCPI4_0 at toc@l(3)
+; CHECK-NEXT: addi 3, 3, .LCPI4_0 at toc@l
+; CHECK-NEXT: lfsx 0, 0, 3
; CHECK-NEXT: lfsx 2, 0, 3
; CHECK-NEXT: addis 3, 2, .LCPI4_2 at toc@ha
; CHECK-NEXT: lfs 3, .LCPI4_1 at toc@l(4)
-; CHECK-NEXT: lfs 1, .LCPI4_2 at toc@l(3)
-; CHECK-NEXT: fmr 4, 3
-; CHECK-NEXT: xsmaddasp 3, 2, 0
-; CHECK-NEXT: xsnmaddasp 4, 2, 0
-; CHECK-NEXT: xsmaddasp 1, 2, 3
-; CHECK-NEXT: xsmaddasp 1, 4, 2
+; CHECK-NEXT: addis 4, 2, .LCPI4_3 at toc@ha
+; CHECK-NEXT: lfs 4, .LCPI4_2 at toc@l(3)
+; CHECK-NEXT: lfs 1, .LCPI4_3 at toc@l(4)
+; CHECK-NEXT: xsmaddasp 3, 0, 2
+; CHECK-NEXT: xsnmsubasp 4, 0, 2
+; CHECK-NEXT: xsmaddasp 1, 0, 3
+; CHECK-NEXT: xsmaddasp 1, 4, 0
; CHECK-NEXT: blr
%tmp = load float, float* undef, align 4
%tmp2 = load float, float* undef, align 4
@@ -205,9 +207,9 @@
; CHECK-FAST-NEXT: addis 4, 2, .LCPI5_0 at toc@ha
; CHECK-FAST-NEXT: lfs 3, .LCPI5_1 at toc@l(3)
; CHECK-FAST-NEXT: lfs 4, .LCPI5_0 at toc@l(4)
-; CHECK-FAST-NEXT: xssubdp 0, 1, 3
+; CHECK-FAST-NEXT: xsadddp 0, 1, 3
; CHECK-FAST-NEXT: xsmaddadp 3, 1, 4
-; CHECK-FAST-NEXT: xsmaddadp 0, 3, 2
+; CHECK-FAST-NEXT: xsnmsubadp 0, 3, 2
; CHECK-FAST-NEXT: fmr 1, 0
; CHECK-FAST-NEXT: blr
;
@@ -218,8 +220,8 @@
; CHECK-FAST-NOVSX-NEXT: lfs 0, .LCPI5_0 at toc@l(3)
; CHECK-FAST-NOVSX-NEXT: lfs 3, .LCPI5_1 at toc@l(4)
; CHECK-FAST-NOVSX-NEXT: fmadd 3, 1, 3, 0
-; CHECK-FAST-NOVSX-NEXT: fsub 0, 1, 0
-; CHECK-FAST-NOVSX-NEXT: fmadd 1, 3, 2, 0
+; CHECK-FAST-NOVSX-NEXT: fadd 0, 1, 0
+; CHECK-FAST-NOVSX-NEXT: fnmsub 1, 3, 2, 0
; CHECK-FAST-NOVSX-NEXT: blr
;
; CHECK-LABEL: getNegatedExpression_crash:
@@ -228,9 +230,9 @@
; CHECK-NEXT: addis 4, 2, .LCPI5_0 at toc@ha
; CHECK-NEXT: lfs 3, .LCPI5_1 at toc@l(3)
; CHECK-NEXT: lfs 4, .LCPI5_0 at toc@l(4)
-; CHECK-NEXT: xssubdp 0, 1, 3
+; CHECK-NEXT: xsadddp 0, 1, 3
; CHECK-NEXT: xsmaddadp 3, 1, 4
-; CHECK-NEXT: xsmaddadp 0, 3, 2
+; CHECK-NEXT: xsnmsubadp 0, 3, 2
; CHECK-NEXT: fmr 1, 0
; CHECK-NEXT: blr
%neg = fneg reassoc double %x
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -13374,12 +13374,6 @@
}
}
- // fold ((fma (fneg X), Y, (fneg Z)) -> fneg (fma X, Y, Z))
- // fold ((fma X, (fneg Y), (fneg Z)) -> fneg (fma X, Y, Z))
- if (!TLI.isFNegFree(VT))
- if (SDValue Neg = TLI.getCheaperNegatedExpression(
- SDValue(N, 0), DAG, LegalOperations, ForCodeSize))
- return DAG.getNode(ISD::FNEG, DL, VT, Neg);
return SDValue();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90901.303364.patch
Type: text/x-patch
Size: 3070 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201106/48e85328/attachment.bin>
More information about the llvm-commits
mailing list