diff options
author | Craig Topper <craig.topper@intel.com> | 2018-09-22 18:03:14 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2018-09-22 18:03:14 +0000 |
commit | e79a588cac812774a38612c43da4601e03e52346 (patch) | |
tree | 95a79c07cd53994625cc09f441ce567f26bff289 /llvm/lib/CodeGen | |
parent | c65d39a46473cad3ff87966619f74aa7ea1a44eb (diff) | |
download | bcm5719-llvm-e79a588cac812774a38612c43da4601e03e52346.tar.gz bcm5719-llvm-e79a588cac812774a38612c43da4601e03e52346.zip |
[DAGCombiner] Rewrite r331896 in a different way to address a FIXME. NFCI
llvm-svn: 342809
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 88d5e78ff1e..0493fde5fa2 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -9852,17 +9852,20 @@ SDValue DAGCombiner::visitBITCAST(SDNode *N) { } // If the input is a constant, let getNode fold it. - // We always need to check that this is just a fp -> int or int -> conversion - // otherwise we will get back N which will confuse the caller into thinking - // we used CombineTo. This can block target combines from running. If we can't - // allowed legal operations, we need to ensure the resulting operation will be - // legal. - // TODO: Maybe we should check that the return value isn't N explicitly? - if ((isa<ConstantSDNode>(N0) && VT.isFloatingPoint() && !VT.isVector() && - (!LegalOperations || TLI.isOperationLegal(ISD::ConstantFP, VT))) || - (isa<ConstantFPSDNode>(N0) && VT.isInteger() && !VT.isVector() && - (!LegalOperations || TLI.isOperationLegal(ISD::Constant, VT)))) - return DAG.getBitcast(VT, N0); + if (isa<ConstantSDNode>(N0) || isa<ConstantFPSDNode>(N0)) { + // If we can't allow illegal operations, we need to check that this is just + // a fp -> int or int -> conversion and that the resulting operation will + // be legal. + if (!LegalOperations || + (isa<ConstantSDNode>(N0) && VT.isFloatingPoint() && !VT.isVector() && + TLI.isOperationLegal(ISD::ConstantFP, VT)) || + (isa<ConstantFPSDNode>(N0) && VT.isInteger() && !VT.isVector() && + TLI.isOperationLegal(ISD::Constant, VT))) { + SDValue C = DAG.getBitcast(VT, N0); + if (C.getNode() != N) + return C; + } + } // (conv (conv x, t1), t2) -> (conv x, t2) if (N0.getOpcode() == ISD::BITCAST) |