[PATCH] [InstCombine] Don't fold bitcast into store if it would need addrspacecast
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 @@
> 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
// values with different sizes, we can't do the transformation.
if (!IC.getDataLayout() ||
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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-commits