[llvm] r362439 - Propagate fmf for setcc/select folds
Michael Berg via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 3 12:12:15 PDT 2019
Author: mcberg2017
Date: Mon Jun 3 12:12:15 2019
New Revision: 362439
URL: http://llvm.org/viewvc/llvm-project?rev=362439&view=rev
Log:
Propagate fmf for setcc/select folds
Summary: This change facilitates propagating fmf which was placed on setcc from fcmp through folds with selects so that back ends can model this path for arithmetic folds on selects in SDAG.
Reviewers: qcolombet, spatel
Reviewed By: qcolombet
Subscribers: nemanjai, jsji
Differential Revision: https://reviews.llvm.org/D62552
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/trunk/test/CodeGen/PowerPC/fmf-propagation.ll
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=362439&r1=362438&r2=362439&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Jun 3 12:12:15 2019
@@ -7941,9 +7941,16 @@ SDValue DAGCombiner::visitSELECT(SDNode
}
if (TLI.isOperationLegal(ISD::SELECT_CC, VT) ||
- (!LegalOperations && TLI.isOperationLegalOrCustom(ISD::SELECT_CC, VT)))
- return DAG.getNode(ISD::SELECT_CC, DL, VT, Cond0, Cond1, N1, N2,
- N0.getOperand(2));
+ (!LegalOperations &&
+ TLI.isOperationLegalOrCustom(ISD::SELECT_CC, VT))) {
+ // Any flags available in a select/setcc fold will be on the setcc as they
+ // migrated from fcmp
+ const SDNodeFlags Flags = N0.getNode()->getFlags();
+ SDValue SelectNode = DAG.getNode(ISD::SELECT_CC, DL, VT, Cond0, Cond1, N1,
+ N2, N0.getOperand(2));
+ SelectNode->setFlags(Flags);
+ return SelectNode;
+ }
return SimplifySelect(DL, N0, N1, N2);
}
Modified: llvm/trunk/test/CodeGen/PowerPC/fmf-propagation.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/fmf-propagation.ll?rev=362439&r1=362438&r2=362439&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/fmf-propagation.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/fmf-propagation.ll Mon Jun 3 12:12:15 2019
@@ -375,11 +375,11 @@ define float @sqrt_fast(float %x) {
; fcmp can have fast-math-flags.
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fcmp_nnan:'
-; FMFDEBUG: select_cc {{t[0-9]+}}
+; FMFDEBUG: select_cc nnan {{t[0-9]+}}
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'fcmp_nnan:'
; GLOBALDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fcmp_nnan:'
-; GLOBALDEBUG: select_cc {{t[0-9]+}}
+; GLOBALDEBUG: select_cc nnan {{t[0-9]+}}
; GLOBALDEBUG: Type-legalized selection DAG: %bb.0 'fcmp_nnan:'
define double @fcmp_nnan(double %a, double %y, double %z) {
More information about the llvm-commits
mailing list