[llvm] r317926 - [DAGcombine] Do not replace truncate node by itself when doing constant folding, this trigger needless extra rounds of combine for nothing. NFC
Friedman, Eli via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 10 13:40:02 PST 2017
On 11/10/2017 12:59 PM, Amaury Sechet via llvm-commits wrote:
> Author: deadalnix
> Date: Fri Nov 10 12:59:53 2017
> New Revision: 317926
>
> URL: http://llvm.org/viewvc/llvm-project?rev=317926&view=rev
> Log:
> [DAGcombine] Do not replace truncate node by itself when doing constant folding, this trigger needless extra rounds of combine for nothing. NFC
>
> Modified:
> llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=317926&r1=317925&r2=317926&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Fri Nov 10 12:59:53 2017
> @@ -8360,12 +8360,18 @@ SDValue DAGCombiner::visitTRUNCATE(SDNod
> // 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)
C.getNode() != N will always be true, I think, due to constant-folding
in getNode(). Or am I missing something?
-Eli
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
More information about the llvm-commits
mailing list