[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:
Simon Pilgrim 2017-05-10 13:06:26 +00:00
parent 21c867c26e
commit cd4d913336
1 changed files with 2 additions and 6 deletions

View File

@ -5534,6 +5534,8 @@ SDValue DAGCombiner::visitSRA(SDNode *N) {
}
// 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)
return N0;
@ -5548,12 +5550,6 @@ SDValue DAGCombiner::visitSRA(SDNode *N) {
ConstantSDNode *N0C = getAsNonOpaqueConstant(N0);
if (N0C && N1C && !N1C->isOpaque())
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
if (N1C && N1C->getAPIntValue().uge(OpSizeInBits))
return DAG.getUNDEF(VT);