HomePhabricator

[LV] Avoid vectorizing loops under opt for size that involve SCEV checks

Description

[LV] Avoid vectorizing loops under opt for size that involve SCEV checks

Fix PR39417, PR39497

The loop vectorizer may generate runtime SCEV checks for overflow and stride==1
cases, leading to execution of original scalar loop. The latter is forbidden
when optimizing for size. An assert introduced in r344743 triggered the above
PR's showing it does happen. This patch fixes this behavior by preventing
vectorization in such cases.

Differential Revision: https://reviews.llvm.org/D53612