[llvm] r176547 - InstCombine: Don't shrink allocas when combining with a bitcast.

Chandler Carruth chandlerc at google.com
Tue Mar 5 21:58:52 PST 2013


On Tue, Mar 5, 2013 at 9:44 PM, Jim Grosbach <grosbach at apple.com> wrote:

> +  // If the allocation has multiple uses, only promote it if we're not
> +  // shrinking the amount of memory being allocated.
> +  uint64_t AllocElTyStoreSize = TD->getTypeStoreSize(AllocElTy);
> +  uint64_t CastElTyStoreSize = TD->getTypeStoreSize(CastElTy);
> +  if (!AI.hasOneUse() && CastElTyStoreSize < AllocElTyStoreSize) return 0;
> +
>

I may just be missing the point (i've not really thought about it deeply)
but I saw this, and hand to ask: why is it safe to shrink the amount of
memory being allocated even if the alloca only has one use?

%a = alloca i32
%a2 = bitcast i32* %a to i8*
%a3 = bitcast i8* %a2 to i32*
%boom = load i32* %a3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130305/44119555/attachment.html>


More information about the llvm-commits mailing list