Issue 203137
Summary [Loop/SCEV] Tail loop of a hand-split strided loop is auto-vectorized despite running fewer than vector length iterations
Labels new issue
Assignees
Reporter kunalspathak
    When a loop is hand-split into a strided main loop (`i += 8` while `i + 8 <= n`) followed by a scalar remainder, `-O3` vectorizes the remainder too — emitting a min-iterations check, a runtime pointer-aliasing (memcheck) guard, a vector body, and a scalar fallback — even though the remainder can run at most 7 times. This is just code bloat: the guards and vector body can never pay off for a loop that short.

This is not specific to intrinsics, to SVE, or to AArch64. The reproducer below is plain scalar C++, and it reproduces on baseline AArch64 NEON (no `-march` needed), on AArch64 with SVE, and on x86-64 with `-mavx2` / `-mavx512f`.

Godbolt: https://godbolt.org/z/WMPxGW59o
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to