[cfe-dev] SCEVAliasAnalysis and AddrSpaceCasts

João Paulo Labegalini de Carvalho via cfe-dev cfe-dev at lists.llvm.org
Fri Nov 20 15:28:00 PST 2020


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?

-- 
João Paulo L. de Carvalho
Computer Science |  IC-UNICAMP | Campinas , SP - Brazil
jaopaulolc at gmail.com
joao.carvalho at ic.unicamp.br
j160924 at dac.unicamp.br
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20201120/362e0272/attachment.html>


More information about the cfe-dev mailing list