From: Craig Topper Date: Sat, 21 Oct 2017 16:35:39 +0000 (+0000) Subject: [ValueTracking] Simplify the known bits code for constant vectors a little. X-Git-Tag: android-x86-7.1-r4~9484 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=3afd582859003b645e0d806a8f32cbebe780f69f;p=android-x86%2Fexternal-llvm.git [ValueTracking] Simplify the known bits code for constant vectors a little. Neither of these cases really require a temporary APInt outside the loop. For the ConstantDataSequential case the APInt will never be larger than 64-bits so its fine to just call getElementAsAPInt. For ConstantVector we can get the APInt by reference and only make a copy where the inversion is needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316265 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 750e6bd3eb5..244bc7d6616 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -1507,9 +1507,8 @@ void computeKnownBits(const Value *V, KnownBits &Known, unsigned Depth, // We know that CDS must be a vector of integers. Take the intersection of // each element. Known.Zero.setAllBits(); Known.One.setAllBits(); - APInt Elt(BitWidth, 0); for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) { - Elt = CDS->getElementAsInteger(i); + APInt Elt = CDS->getElementAsAPInt(i); Known.Zero &= ~Elt; Known.One &= Elt; } @@ -1520,7 +1519,6 @@ void computeKnownBits(const Value *V, KnownBits &Known, unsigned Depth, // We know that CV must be a vector of integers. Take the intersection of // each element. Known.Zero.setAllBits(); Known.One.setAllBits(); - APInt Elt(BitWidth, 0); for (unsigned i = 0, e = CV->getNumOperands(); i != e; ++i) { Constant *Element = CV->getAggregateElement(i); auto *ElementCI = dyn_cast_or_null(Element); @@ -1528,7 +1526,7 @@ void computeKnownBits(const Value *V, KnownBits &Known, unsigned Depth, Known.resetAll(); return; } - Elt = ElementCI->getValue(); + const APInt &Elt = ElementCI->getValue(); Known.Zero &= ~Elt; Known.One &= Elt; }