mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 19:12:56 +02:00
[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
This commit is contained in:
parent
7497a5ca3a
commit
f3e0c5f2ce
@ -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 ||
|
||||
|
Loading…
Reference in New Issue
Block a user