Commit 1d976c6
[LV] Ignore user-specified interleave count when unsafe. (llvm#153009)
When an VF is specified via a loop hint, it will be clamped to a safe
VF or ignored if it is found to be unsafe. This is not the case for
user-specified interleave counts, which can lead to loops such as
the following with a memory dependence being vectorised with
interleaving:
```
#pragma clang loop interleave_count(4)
for (int i = 4; i < LEN; i++)
b[i] = b[i - 4] + a[i];
```
According to [1], loop hints are ignored if they are not safe to apply.
This patch adds a check to prevent vectorisation with interleaving if
isSafeForAnyVectorWidth() returns false. This is already checked in
selectInterleaveCount().
[1]
https://llvm.org/docs/LangRef.html#llvm-loop-vectorize-and-llvm-loop-interleave1 parent 4d53297 commit 1d976c6
File tree
3 files changed
+46
-10
lines changed- llvm
- lib/Transforms/Vectorize
- test/Transforms/LoopVectorize
- AArch64
3 files changed
+46
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9860 | 9860 | | |
9861 | 9861 | | |
9862 | 9862 | | |
| 9863 | + | |
| 9864 | + | |
9863 | 9865 | | |
9864 | 9866 | | |
9865 | 9867 | | |
| |||
9924 | 9926 | | |
9925 | 9927 | | |
9926 | 9928 | | |
9927 | | - | |
| 9929 | + | |
| 9930 | + | |
| 9931 | + | |
| 9932 | + | |
| 9933 | + | |
| 9934 | + | |
| 9935 | + | |
| 9936 | + | |
| 9937 | + | |
9928 | 9938 | | |
9929 | 9939 | | |
9930 | 9940 | | |
| |||
Lines changed: 5 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
420 | | - | |
| 420 | + | |
| 421 | + | |
421 | 422 | | |
422 | 423 | | |
423 | 424 | | |
424 | 425 | | |
425 | 426 | | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
| 427 | + | |
| 428 | + | |
432 | 429 | | |
433 | | - | |
434 | | - | |
| 430 | + | |
435 | 431 | | |
436 | 432 | | |
437 | 433 | | |
| |||
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
0 commit comments