]> granicus.if.org Git - llvm/commitdiff
[DAGCombiner] Dropped explicit (sra 0, x) -> 0 and (sra -1, x) -> 0 folds.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 10 May 2017 13:06:26 +0000 (13:06 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 10 May 2017 13:06:26 +0000 (13:06 +0000)
These are both handled (and tested) by the earlier ComputeNumSignBits == EltSizeInBits fold.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302651 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index 2436a81259fc8c8f81d47863cac86118348beef3..1da8fe7626301b47ca5b354ae2fd96a39bf7a671 100644 (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);