[llvm-commits] [llvm] r128332 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp

Cameron Zwarich zwarich at apple.com
Sat Mar 26 01:12:02 PDT 2011


Test?

Cameron

On 2011-03-26, at 1:02 AM, Bill Wendling wrote:

> Author: void
> Date: Sat Mar 26 03:02:59 2011
> New Revision: 128332
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=128332&view=rev
> Log:
> Rework the logic that determines if a store completely overlaps an ealier store.
> 
> There are two ways that a later store can comletely overlap a previous store:
> 
> 1. They both start at the same offset, but the earlier store's size is <= the
>   later's size, or
> 2. The earlier store's offset is > the later's offset, but it's offset + size
>   doesn't extend past the later's offset + size.
> 
> Modified:
>    llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
> 
> Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=128332&r1=128331&r2=128332&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Sat Mar 26 03:02:59 2011
> @@ -340,26 +340,34 @@
>   // Okay, we have stores to two completely different pointers.  Try to
>   // decompose the pointer into a "base + constant_offset" form.  If the base
>   // pointers are equal, then we can reason about the two stores.
> -  int64_t Off1 = 0, Off2 = 0;
> -  const Value *BP1 = GetPointerBaseWithConstantOffset(P1, Off1, TD);
> -  const Value *BP2 = GetPointerBaseWithConstantOffset(P2, Off2, TD);
> +  int64_t EarlierOff = 0, LaterOff = 0;
> +  const Value *BP1 = GetPointerBaseWithConstantOffset(P1, EarlierOff, TD);
> +  const Value *BP2 = GetPointerBaseWithConstantOffset(P2, LaterOff, TD);
> 
>   // If the base pointers still differ, we have two completely different stores.
>   if (BP1 != BP2)
>     return false;
> -  
> -  // Otherwise, we might have a situation like:
> -  //  store i16 -> P + 1 Byte
> -  //  store i32 -> P
> -  // In this case, we see if the later store completely overlaps all bytes
> -  // stored by the previous store.
> -  if (Off1 < Off2 ||                       // Earlier starts before Later.
> -      Off2 < 0 ||                          // Later is -.
> -      Off1+Earlier.Size > Off2+Later.Size) // Earlier goes beyond Later.
> -    return false;
> 
> -  // Otherwise, we have complete overlap.
> -  return true;
> +  // The later store completely overlaps the earlier store if:
> +  // 
> +  // 1. Both start at the same offset and the later one's size is greater than
> +  //    or equal to the earlier one's, or
> +  //
> +  //      |--earlier--|
> +  //      |--   later   --|
> +  //      
> +  // 2. The earlier store has an offset greater than the later offset, but which
> +  //    still lies completely within the later store.
> +  //
> +  //        |--earlier--|
> +  //    |-----  later  ------|
> +  if ((EarlierOff == LaterOff && Earlier.Size <= Later.Size) ||
> +      (EarlierOff > LaterOff &&
> +       EarlierOff + Earlier.Size <= LaterOff + Later.Size))
> +    return true;
> +
> +  // Otherwise, they don't completely overlap.
> +  return false;
> }
> 
> /// isPossibleSelfRead - If 'Inst' might be a self read (i.e. a noop copy of a
> 
> 
> _______________________________________________
> 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