Index: lib/Analysis/ValueTracking.cpp =================================================================== --- lib/Analysis/ValueTracking.cpp +++ lib/Analysis/ValueTracking.cpp @@ -1462,9 +1462,18 @@ return; } - // The address of an aligned GlobalValue has trailing zeros. + // Start out not knowing anything. + KnownZero.clearAllBits(); KnownOne.clearAllBits(); + + // Limit search depth. + // All recursive calls that increase depth must come after this. + if (Depth == MaxDepth) + return; + + // If V is a pointer check if we know it's alignment + unsigned Align = 0; if (auto *GO = dyn_cast(V)) { - unsigned Align = GO->getAlignment(); + Align = GO->getAlignment(); if (Align == 0) { if (auto *GVar = dyn_cast(GO)) { Type *ObjectType = GVar->getType()->getElementType(); @@ -1479,17 +1488,8 @@ } } } - if (Align > 0) - KnownZero = APInt::getLowBitsSet(BitWidth, - countTrailingZeros(Align)); - else - KnownZero.clearAllBits(); - KnownOne.clearAllBits(); - return; - } - - if (Argument *A = dyn_cast(V)) { - unsigned Align = A->getType()->isPointerTy() ? A->getParamAlignment() : 0; + } else if (Argument *A = dyn_cast(V)) { + Align = A->getType()->isPointerTy() ? A->getParamAlignment() : 0; if (!Align && A->hasStructRetAttr()) { // An sret parameter has at least the ABI alignment of the return type. @@ -1497,31 +1497,11 @@ if (EltTy->isSized()) Align = DL.getABITypeAlignment(EltTy); } - - if (Align) - KnownZero = APInt::getLowBitsSet(BitWidth, countTrailingZeros(Align)); - else - KnownZero.clearAllBits(); - KnownOne.clearAllBits(); - - // Don't give up yet... there might be an assumption that provides more - // information... - computeKnownBitsFromAssume(V, KnownZero, KnownOne, DL, Depth, Q); - - // Or a dominating condition for that matter - if (EnableDomConditions && Depth <= DomConditionsMaxDepth) - computeKnownBitsFromDominatingCondition(V, KnownZero, KnownOne, DL, - Depth, Q); - return; } - // Start out not knowing anything. - KnownZero.clearAllBits(); KnownOne.clearAllBits(); - - // Limit search depth. - // All recursive calls that increase depth must come after this. - if (Depth == MaxDepth) - return; + // Aligned pointers have trailing zeros + if (Align) + KnownZero = APInt::getLowBitsSet(BitWidth, countTrailingZeros(Align)); // A weak GlobalAlias is totally unknown. A non-weak GlobalAlias has // the bits of its aliasee.