forked from OSchip/llvm-project
[DAGCombiner] Dropped explicit (sra 0, x) -> 0 and (sra -1, x) -> 0 folds.
These are both handled (and tested) by the earlier ComputeNumSignBits == EltSizeInBits fold. llvm-svn: 302651
This commit is contained in:
parent
21c867c26e
commit
cd4d913336
|
@ -5534,6 +5534,8 @@ SDValue DAGCombiner::visitSRA(SDNode *N) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arithmetic shifting an all-sign-bit value is a no-op.
|
// Arithmetic shifting an all-sign-bit value is a no-op.
|
||||||
|
// fold (sra 0, x) -> 0
|
||||||
|
// fold (sra -1, x) -> -1
|
||||||
if (DAG.ComputeNumSignBits(N0) == OpSizeInBits)
|
if (DAG.ComputeNumSignBits(N0) == OpSizeInBits)
|
||||||
return N0;
|
return N0;
|
||||||
|
|
||||||
|
@ -5548,12 +5550,6 @@ SDValue DAGCombiner::visitSRA(SDNode *N) {
|
||||||
ConstantSDNode *N0C = getAsNonOpaqueConstant(N0);
|
ConstantSDNode *N0C = getAsNonOpaqueConstant(N0);
|
||||||
if (N0C && N1C && !N1C->isOpaque())
|
if (N0C && N1C && !N1C->isOpaque())
|
||||||
return DAG.FoldConstantArithmetic(ISD::SRA, SDLoc(N), VT, N0C, N1C);
|
return DAG.FoldConstantArithmetic(ISD::SRA, SDLoc(N), VT, N0C, N1C);
|
||||||
// fold (sra 0, x) -> 0
|
|
||||||
if (isNullConstant(N0))
|
|
||||||
return N0;
|
|
||||||
// fold (sra -1, x) -> -1
|
|
||||||
if (isAllOnesConstant(N0))
|
|
||||||
return N0;
|
|
||||||
// fold (sra x, c >= size(x)) -> undef
|
// fold (sra x, c >= size(x)) -> undef
|
||||||
if (N1C && N1C->getAPIntValue().uge(OpSizeInBits))
|
if (N1C && N1C->getAPIntValue().uge(OpSizeInBits))
|
||||||
return DAG.getUNDEF(VT);
|
return DAG.getUNDEF(VT);
|
||||||
|
|
Loading…
Reference in New Issue