[PATCH] Teach ValueTracking about address spaces
Matt Arsenault
arsenm2 at gmail.com
Fri Aug 2 17:14:48 PDT 2013
On Aug 2, 2013, at 16:51 , Eli Friedman <eli.friedman at gmail.com> wrote:
> On Thu, Aug 1, 2013 at 2:22 PM, Matt Arsenault
> <Matthew.Arsenault at amd.com> wrote:
>> This is required for
>>
>> http://llvm-reviews.chandlerc.com/D1250
>>
>> I don't have a test for this using different address spaces until some other pieces are also in.
>>
>> http://llvm-reviews.chandlerc.com/D1262
>>
>> Files:
>> lib/Analysis/ValueTracking.cpp
>>
>> Index: lib/Analysis/ValueTracking.cpp
>> ===================================================================
>> --- lib/Analysis/ValueTracking.cpp
>> +++ lib/Analysis/ValueTracking.cpp
>> @@ -39,8 +39,8 @@
>> static unsigned getBitWidth(Type *Ty, const DataLayout *TD) {
>> if (unsigned BitWidth = Ty->getScalarSizeInBits())
>> return BitWidth;
>> - assert(isa<PointerType>(Ty) && "Expected a pointer type!");
>> - return TD ? TD->getPointerSizeInBits() : 0;
>> +
>> + return TD ? TD->getPointerTypeSizeInBits(Ty) : 0;
>> }
>>
>> static void ComputeMaskedBitsAddSub(bool Add, Value *Op0, Value *Op1, bool NSW,
>> @@ -1704,20 +1704,25 @@
>> /// it can be expressed as a base pointer plus a constant offset. Return the
>> /// base and offset to the caller.
>> Value *llvm::GetPointerBaseWithConstantOffset(Value *Ptr, int64_t &Offset,
>> - const DataLayout *TD) {
>> + const DataLayout *DL) {
>> // Without DataLayout, conservatively assume 64-bit offsets, which is
>> // the widest we support.
>> - unsigned BitWidth = TD ? TD->getPointerSizeInBits() : 64;
>> + unsigned BitWidth = DL ? DL->getPointerTypeSizeInBits(Ptr->getType()) : 64;
>> APInt ByteOffset(BitWidth, 0);
>> while (1) {
>> if (Ptr->getType()->isVectorTy())
>> break;
>>
>> if (GEPOperator *GEP = dyn_cast<GEPOperator>(Ptr)) {
>> - APInt GEPOffset(BitWidth, 0);
>> - if (TD && !GEP->accumulateConstantOffset(*TD, GEPOffset))
>> - break;
>> - ByteOffset += GEPOffset;
>> + if (DL) {
>> + BitWidth = DL->getPointerTypeSizeInBits(Ptr->getType());
>
> Why do you need to reset BitWidth every iteration of the loop? Didn't
> you already commit the verifier patches which guarantee BitWidth will
> be the same for every iteration of the loop?
It doesn't, I'll remove it. I don't know why it's there.
More information about the llvm-commits
mailing list