Skip to content

Conversation

2001SameerSharma
Copy link

Add a regression test that checks the loop vectorizer produces distinct IR for fixed-width vs scalable vectorization on AArch64 with SVE. Verifies we still generate semantically equivalent loops under both modes.

Copy link

github-actions bot commented Oct 1, 2025

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented Oct 1, 2025

@llvm/pr-subscribers-llvm-transforms

Author: None (2001SameerSharma)

Changes

Add a regression test that checks the loop vectorizer produces distinct IR for fixed-width vs scalable vectorization on AArch64 with SVE. Verifies we still generate semantically equivalent loops under both modes.


Full diff: https://github.com/llvm/llvm-project/pull/161489.diff

1 Files Affected:

  • (added) llvm/test/Transforms/LoopVectorize/idiv-sum-sve.ll (+36)
diff --git a/llvm/test/Transforms/LoopVectorize/idiv-sum-sve.ll b/llvm/test/Transforms/LoopVectorize/idiv-sum-sve.ll
new file mode 100644
index 0000000000000..2a6ee4ba99984
--- /dev/null
+++ b/llvm/test/Transforms/LoopVectorize/idiv-sum-sve.ll
@@ -0,0 +1,36 @@
+; NOTE: This test checks that the loop vectorizer produces different IR shapes
+;       under fixed-width and scalable vectorization, but both should remain
+;       valid and semantically equivalent.
+
+; RUN: opt -S -mtriple=aarch64-linux-gnu -scalable-vectorization=off \
+; RUN:   -passes=loop-vectorize < %s | FileCheck %s --check-prefix=FIXED
+; RUN: opt -S -mtriple=aarch64-linux-gnu -mattr=+sve -scalable-vectorization=on \
+; RUN:   -passes=loop-vectorize < %s | FileCheck %s --check-prefix=SVE
+
+define i32 @idiv_sum(ptr nocapture readonly %a,
+                     ptr nocapture readonly %b, i32 %n) {
+entry:
+  %s = alloca i32, align 4
+  store i32 0, ptr %s, align 4
+  %cmp = icmp sgt i32 %n, 0
+  br i1 %cmp, label %loop, label %exit
+
+loop:                                             ; preds = %entry, %loop
+  %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
+  %acc = phi i32 [ 0, %entry ], [ %sum, %loop ]
+  %a.val = load i32, ptr %a
+  %b.val = load i32, ptr %b
+  %div = sdiv i32 %a.val, %b.val
+  %sum = add i32 %acc, %div
+  %i.next = add i32 %i, 1
+  %cmp.loop = icmp slt i32 %i.next, %n
+  br i1 %cmp.loop, label %loop, label %exit
+
+exit:                                             ; preds = %loop, %entry
+  %res = phi i32 [ 0, %entry ], [ %sum, %loop ]
+  ret i32 %res
+}
+
+; FIXED-LABEL: vector.body:
+; SVE-LABEL: vector.body:
+; SVE: <vscale x 4 x i32>

Copy link
Contributor

@fhahn fhahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this add test coverage that is currently missing?

@2001SameerSharma
Copy link
Author

I checked the existing llvm/test/Transforms/LoopVectorize tests. There are tests that run with scalable vectorization enabled and others with it disabled, but I didn’t find one that runs the same loop under both modes on AArch64 and compares the IR shapes while ensuring semantic equivalence. This test adds that explicit coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants