[llvm] [LV] Derive max trip count for remainder loops through LCSSA phis (PR #206887)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 20 01:21:58 PDT 2026


================
@@ -0,0 +1,126 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -passes=loop-vectorize -S | FileCheck %s
+;
+; When a remainder loop follows a stride-8 main loop, the remainder loop
+; has a proven max trip count of 7 (it handles n%8 elements). SCEV fails
+; to derive this bound because it does not trace the LCSSA phi back to the
+; preceding loop's exit condition. The loop vectorizer should detect this
+; "remainder of stride" pattern and avoid vectorizing the remainder loop
+; since its trip count is too small to benefit from vectorization.
+
+target triple = "x86_64-unknown-linux-gnu"
----------------
david-arm wrote:

This is an X86 specific test, which means it should live in test/Transforms/LoopVectorize/X86 or something like that.

https://github.com/llvm/llvm-project/pull/206887


More information about the llvm-commits mailing list