diff options
author | Amaury Sechet <deadalnix@gmail.com> | 2017-11-10 20:59:53 +0000 |
---|---|---|
committer | Amaury Sechet <deadalnix@gmail.com> | 2017-11-10 20:59:53 +0000 |
commit | 3f0f650f498d97516745678b304a1649c3b2450f (patch) | |
tree | b77b5197783432e1a7415bc501e200cffe8afeca /llvm/lib/CodeGen | |
parent | 0f2ce11df7288c4cdae0db2f7211ec41446e6c22 (diff) | |
download | bcm5719-llvm-3f0f650f498d97516745678b304a1649c3b2450f.tar.gz bcm5719-llvm-3f0f650f498d97516745678b304a1649c3b2450f.zip |
[DAGcombine] Do not replace truncate node by itself when doing constant folding, this trigger needless extra rounds of combine for nothing. NFC
llvm-svn: 317926
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 557cf6d5212..dd8d613dcf7 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -8360,12 +8360,18 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) { // noop truncate if (N0.getValueType() == N->getValueType(0)) return N0; - // fold (truncate c1) -> c1 - if (DAG.isConstantIntBuildVectorOrConstantInt(N0)) - return DAG.getNode(ISD::TRUNCATE, SDLoc(N), VT, N0); + // fold (truncate (truncate x)) -> (truncate x) if (N0.getOpcode() == ISD::TRUNCATE) return DAG.getNode(ISD::TRUNCATE, SDLoc(N), VT, N0.getOperand(0)); + + // fold (truncate c1) -> c1 + if (DAG.isConstantIntBuildVectorOrConstantInt(N0)) { + SDValue C = DAG.getNode(ISD::TRUNCATE, SDLoc(N), VT, N0); + if (C.getNode() != N) + return C; + } + // fold (truncate (ext x)) -> (ext x) or (truncate x) or x if (N0.getOpcode() == ISD::ZERO_EXTEND || N0.getOpcode() == ISD::SIGN_EXTEND || |