SCEVAliasAnalysis and AddrSpaceCasts

Hi,

I recently found that loops that operate on non-aliased SYCL buffers are not being vectorized. After a little digging the root cause reviewed to be the fact that there is a AddrSpaceCast instruction between a load and the respective GetElementPointer computing the access effective address.

From the LLVM IR language spec I learned that AddrSpaceCast might change the pointer value using a target specific function. But, not for all targets. In fact, in the TargetTransformationInfo there is a predicate method isNoopAddrSpaceCast(FromAS, ToAS) that returns true if the cast is a noop depending on FromAS and ToAS.

I hacked the lib/Analysis/ScalarEvolution.cpp and lib/Transforms/Utils/ScalarEvolutionExpander.cpp files to handle AddrSpaceCasts. WIth these changes the compiler was able to vectorize the loop if it is annotated with #pragma clang loop vectorize(enable)…

My question is, would it be safe to allow such changes whenever the isNoopAddrSpaceCast() predicate evaluates to true? Or am I not considering something?