[clang] [llvm] [LV][LAA] Vectorize math lib calls with mem write-only attribute (PR #78432)
Maciej Gabka via cfe-commits
cfe-commits at lists.llvm.org
Wed May 15 09:47:26 PDT 2024
================
@@ -2477,6 +2493,15 @@ void LoopAccessInfo::analyzeLoop(AAResults *AA, LoopInfo *LI,
// Save 'store' instructions. Abort if other instructions write to memory.
if (I.mayWriteToMemory()) {
+ // We can safety handle math functions that have vectorized
+ // counterparts and have the memory write-only attribute set.
----------------
mgabka wrote:
Hi @fhahn,
you are right.
The whole logic was based on checking later in the https://github.com/llvm/llvm-project/blob/332de4b2677ce7a95cc2df30d761fbb55376fe07/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp#L6659 if the pointers are linear with the right step, but there is no checks for aliasing.
@paschalis-mpeis that means that there is an existing bug with sincos, as following code gets vectorised, without any checks:
```
double sin[N];
double cos[N];
sin[5] = M_PI;
for(int i=0; i<N; i++ ) {
sincos(sin[5], sin+i, cos+i);
}
```
https://github.com/llvm/llvm-project/pull/78432
More information about the cfe-commits
mailing list