[llvm-branch-commits] [llvm] [LoopVectorize] Support vectorization of compressing patterns (PR #214491)

Andrei Elovikov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Aug 17 11:19:17 PDT 2026


================
@@ -0,0 +1,94 @@
+; RUN: opt < %s -lv-monotonic-patterns=true -force-target-supports-masked-memory-ops -force-vector-width=4 -passes=loop-vectorize -disable-output -pass-remarks-analysis=".*" 2>&1 | FileCheck %s
+
+; CHECK: loop not vectorized: cannot identify array bounds
+
+; Negative test: Conditional pointer (rather than index) increments are not supported yet (needs LAA support).
+define void @test_compress_store_with_pointer(ptr writeonly noalias %init.dst, ptr readonly %src, i32 %c, i64 %n) {
+entry:
+  br label %for.body
+
+for.body:
+  %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.inc ]
+  %dst = phi ptr [ %init.dst, %entry ], [ %dst.1, %for.inc ]
+  %src.ptr = getelementptr inbounds i32, ptr %src, i64 %iv
+  %load.src = load i32, ptr %src.ptr, align 4
+  %cmp = icmp slt i32 %load.src, %c
+  br i1 %cmp, label %if.then, label %for.inc
+
+if.then:
+  %dst.inc = getelementptr inbounds i8, ptr %dst, i64 4
+  store i32 %load.src, ptr %dst, align 4
+  br label %for.inc
+
+for.inc:
+  %dst.1 = phi ptr [ %dst.inc, %if.then ], [ %dst, %for.body ]
+  %iv.next = add nuw nsw i64 %iv, 1
+  %exitcond.not = icmp eq i64 %iv.next, %n
+  br i1 %exitcond.not, label %exit, label %for.body
+
+exit:
+  ret void
+}
+
+; CHECK: loop not vectorized: value that could not be identified as reduction is used outside the loop
+
+; Negative test: Storing the conditionally incremented phi is invalid (as all uses must be uniform).
----------------
eas wrote:

"Uniformity" isn't what's being used anymore, the comment needs to be updated, I think.

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


More information about the llvm-branch-commits mailing list