[PATCH] [InstCombine] Don't fold bitcast into store if it would need addrspacecast
Richard Osborne
richard at xmos.com
Wed Mar 19 11:13:02 PDT 2014
On 19/03/14 17:40, Matt Arsenault wrote:
>
> Index: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
> ===================================================================
> --- lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
> +++ lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
> @@ -517,27 +517,35 @@
> IC.getDataLayout()->getTypeSizeInBits(DestPTy))
> return 0;
>
> + // Don't introduce casts between pointers to different address spaces. We
> + // can't use the addrspacecast instruction in this case since, depending on
> + // the target, addrspacecast may not be a no-op cast.
> + if (SrcPTy->isPointerTy() && DestPTy->isPointerTy() &&
> + cast<PointerType>(SrcPTy)->getAddressSpace() !=
> + cast<PointerType>(DestPTy)->getAddressSpace())
> + return 0;
> +
>
> Right above here is a check leftover from when bitcast was allowed if
> the pointers were the same size. You should update that and replace it
> with this.
Are you talking about this code?
// If the pointers point into different address spaces or if they
point to
// values with different sizes, we can't do the transformation.
if (!IC.getDataLayout() ||
SrcTy->getAddressSpace() !=
cast<PointerType>(CI->getType())->getAddressSpace() ||
IC.getDataLayout()->getTypeSizeInBits(SrcPTy) !=
IC.getDataLayout()->getTypeSizeInBits(DestPTy))
return 0;
I think the address space check here is still required. It might be
cleaner to bailout earlier on if the cast instruction is an address
space cast instead of a bitcast. Is that what you had in mind?
--
Richard Osborne | XMOS
http://www.xmos.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140319/e2d663ee/attachment.html>
More information about the llvm-commits
mailing list