SCEVAliasAnalysis and AddrSpaceCasts

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

SCEVAliasAnalysis and AddrSpaceCasts

David Blaikie via cfe-dev

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?

João Paulo L. de Carvalho
Computer Science |  IC-UNICAMP | Campinas , SP - Brazil

cfe-dev mailing list
[hidden email]