<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/98487>98487</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Disable vectorisation during pre-link LTO stage
</td>
</tr>
<tr>
<th>Labels</th>
<td>
vectorization,
LTO
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
igogo-x86
</td>
</tr>
</table>
<pre>
There is a scenario when the PreLTO LoopVectorize fails to vectorise code, and SLPVectorizer would transform some chunks of code within the loop. During link-time LTO, new opportunities after inlining may allow to vectorise loop, but it would be spoiled by SLP. I don't see how this can be resolved optimally without changing the optimisation pipeline.
My real-life example is like this:
```
void func {
a = malloc();
b = malloc();
c = malloc();
...
would_be_inlined(a, b, c, ...);
}
void would_be_inlined(a, b, c, ...) {
...
loop {
// Writes to a, b and c only. Reads from some other pointers
// Before inlining LLVM does not know that write pointers don't alias read pointers and thus does not vectorise
// After LTO vectorisation is highly profitable but SLP already spoils the loop with overall legit optimisations.
}
...
}
```
I can also imagine a scenario where small functions get inlined into a loop only after SLP vectorised.
GCC doesn't run vectorisation before LTO. I wonder if LLVM could do the same and where resistance against it comes from. Surely, there will be some regressions, but they couldn't be as unsolvable as the one described above.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVVFv4joT_TXmZUQUTArhIQ-7Rf20EqtWX6u9jysnniRz63gi24Flf_2VHUpLr7S6EjIQ2zNnzjkzUd5TZxErcfdV3O0Xago9u4o67nj5q9wsatbn6qVHh0AeFPgGrXLEcOrRQugRnhweXh7hwDz-wCawo98IrSLjITAc50ceoWGNQt6DshqeD0_Xsw5OPBkNwSnrW3YDeB4Qmn6yrx64TRfhRKGnOaFhHjPYT45sB4bs6zLQgHB4eYzhLZ6Ax5FdmCwFQg-qDeiArCEbbwzqDMoYPt3Ci1Hj_XoKQOGCqUbwI5NBDfU5os7gG2i2Qm4DeEToY5iePDTKxtMOPZ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