[PATCH] Teach ValueTracking about address spaces
Eli Friedman
eli.friedman at gmail.com
Fri Aug 9 20:26:11 PDT 2013
Looks fine.
-Eli
On Mon, Aug 5, 2013 at 10:49 AM, Matt Arsenault
<Matthew.Arsenault at amd.com> wrote:
> Don't re-get bitwidth in the loop
>
> Hi void,
>
> http://llvm-reviews.chandlerc.com/D1262
>
> CHANGE SINCE LAST DIFF
> http://llvm-reviews.chandlerc.com/D1262?vs=3133&id=3197#toc
>
> 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,24 @@
> /// 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) {
> + APInt GEPOffset(BitWidth, 0);
> + if (!GEP->accumulateConstantOffset(*DL, GEPOffset))
> + break;
> +
> + ByteOffset += GEPOffset;
> + }
> +
> Ptr = GEP->getPointerOperand();
> } else if (Operator::getOpcode(Ptr) == Instruction::BitCast) {
> Ptr = cast<Operator>(Ptr)->getOperand(0);
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list