From 2602091f822fc2b3d64b1a0c15e1f661e47c7143 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Fri, 21 Apr 2017 16:43:32 +0000 Subject: [PATCH] [ValueTracking] Use APInt::setAllBits and APInt::intersects to simplify some code. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300997 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ValueTracking.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 900a2363e60..e2ffa440c90 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -778,7 +778,7 @@ static void computeKnownBitsFromAssume(const Value *V, APInt &KnownZero, // 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 computeKnownBitsFromShiftOperator( 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 computeKnownBitsFromShiftOperator( // 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(); } -- 2.11.0