[DAGCombiner] Slightly simplify some code by using APInt::isMask() and countTrailingO...
authorCraig Topper <craig.topper@intel.com>
Thu, 21 Sep 2017 20:12:19 +0000 (20:12 +0000)
committerCraig Topper <craig.topper@intel.com>
Thu, 21 Sep 2017 20:12:19 +0000 (20:12 +0000)
At least for the 64-bit and less case, we should be able to determine if we even have a mask without counting any bits. This also removes the need to explicitly check for 0 active bits, isMask will return false for 0.

llvm-svn: 313908

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index d9b56bf..7b499c2 100644 (file)
@@ -3666,11 +3666,11 @@ SDValue DAGCombiner::visitANDLike(SDValue N0, SDValue N1, SDNode *N) {
 bool DAGCombiner::isAndLoadExtLoad(ConstantSDNode *AndC, LoadSDNode *LoadN,
                                    EVT LoadResultTy, EVT &ExtVT, EVT &LoadedVT,
                                    bool &NarrowLoad) {
-  uint32_t ActiveBits = AndC->getAPIntValue().getActiveBits();
-
-  if (ActiveBits == 0 || !AndC->getAPIntValue().isMask(ActiveBits))
+  if (!AndC->getAPIntValue().isMask())
     return false;
 
+  unsigned ActiveBits = AndC->getAPIntValue().countTrailingOnes();
+
   ExtVT = EVT::getIntegerVT(*DAG.getContext(), ActiveBits);
   LoadedVT = LoadN->getMemoryVT();