[llvm] r300997 - [ValueTracking] Use APInt::setAllBits and APInt::intersects to simplify some code. NFC

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 21 09:43:32 PDT 2017


Author: ctopper
Date: Fri Apr 21 11:43:32 2017
New Revision: 300997

URL: http://llvm.org/viewvc/llvm-project?rev=300997&view=rev
Log:
[ValueTracking] Use APInt::setAllBits and APInt::intersects to simplify some code. NFC

Modified:
    llvm/trunk/lib/Analysis/ValueTracking.cpp

Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=300997&r1=300996&r2=300997&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Fri Apr 21 11:43:32 2017
@@ -778,7 +778,7 @@ static void computeKnownBitsFromAssume(c
   // so this isn't a real bug. On the other hand, the program may have undefined
   // behavior, or we might have a bug in the compiler. We can't assert/crash, so
   // clear out the known bits, try to warn the user, and hope for the best.
-  if ((KnownZero & KnownOne) != 0) {
+  if (KnownZero.intersects(KnownOne)) {
     KnownZero.clearAllBits();
     KnownOne.clearAllBits();
 
@@ -860,7 +860,8 @@ static void computeKnownBitsFromShiftOpe
 
   computeKnownBits(I->getOperand(0), KnownZero2, KnownOne2, Depth + 1, Q);
 
-  KnownZero = KnownOne = APInt::getAllOnesValue(BitWidth);
+  KnownZero.setAllBits();
+  KnownOne.setAllBits();
   for (unsigned ShiftAmt = 0; ShiftAmt < BitWidth; ++ShiftAmt) {
     // Combine the shifted known input bits only for those shift amounts
     // compatible with its known constraints.
@@ -888,7 +889,7 @@ static void computeKnownBitsFromShiftOpe
   // return anything we'd like, but we need to make sure the sets of known bits
   // stay disjoint (it should be better for some other code to actually
   // propagate the undef than to pick a value here using known bits).
-  if ((KnownZero & KnownOne) != 0) {
+  if (KnownZero.intersects(KnownOne)) {
     KnownZero.clearAllBits();
     KnownOne.clearAllBits();
   }




More information about the llvm-commits mailing list