[llvm] r189007 - Teach the SLP vectorizer the correct way to check for consecutive access

Nadav Rotem nrotem at apple.com
Thu Aug 22 09:32:33 PDT 2013


Hi Chandler, 

Thanks for working on this. Did you measure the difference in compile time of this patch on the LLVM test suite?  The original code avoided calling accumulateConstantOffset when possible because it is somewhat expensive.  I like your pass-wide memoization idea. :) 

> 
> +  APInt OffsetA(PtrBitWidth, 0), OffsetB(PtrBitWidth, 0);
> +  PtrA = PtrA->stripAndAccumulateInBoundsConstantOffsets(*DL, OffsetA);
> +  PtrB = PtrB->stripAndAccumulateInBoundsConstantOffsets(*DL, OffsetB);
> 
> -  // Check if PtrB is the base and PtrA is a constant offset.
> -  if (GepA && GepA->getPointerOperand() == PtrB) {
> -    APInt Offset(BW, 0);
> -    if (GepA->accumulateConstantOffset(*DL, Offset))
> -      return Offset.getSExtValue() == -Sz;
> -    return false;
> -  }
> +  APInt OffsetDelta = OffsetB - OffsetA;
> +
> +  // Check if they are based on the same pointer. That makes the offsets
> +  // sufficient.
> +  if (PtrA == PtrB)
> +    return OffsetDelta == Size;
> 

What happens if both PtrA and PtrB are zero ?  This means that both OffsetA and OffsetB are garbage. You need to check if at least one of the calls to stripAndAccumulate succeeded. 

Thanks,
Nadav




More information about the llvm-commits mailing list