[llvm] [LLVM][Verifier] Remove constant-only matrix stride check (PR #207665)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 6 00:05:10 PDT 2026
https://github.com/mayanksolanki393 created https://github.com/llvm/llvm-project/pull/207665
Remove the verifier check requiring constant column-major matrix
load/store strides to be greater than or equal to the row count.
The stride operand is not an immarg, so the verifier must not enforce
constraints that only apply when the argument happens to be constant.
>From 14929ecc01c459bba071ba55c66b44047ee22906 Mon Sep 17 00:00:00 2001
From: Mayank Solanki <mayank.solanki at amd.com>
Date: Mon, 6 Jul 2026 12:29:52 +0530
Subject: [PATCH] [LLVM][Verifier] Remove constant-only matrix stride check
Remove the verifier check requiring constant column-major matrix
load/store strides to be greater than or equal to the row count.
The stride operand is not an immarg, so the verifier must not enforce
constraints that only apply when the argument happens to be constant.
Add coverage for an inline case where a non-constant stride is folded to
a smaller constant stride.
---
llvm/lib/IR/Verifier.cpp | 2 --
llvm/test/Verifier/matrix-intrinsics-inline.ll | 18 ++++++++++++++++++
llvm/test/Verifier/matrix-intrinsics.ll | 18 ------------------
3 files changed, 18 insertions(+), 20 deletions(-)
create mode 100644 llvm/test/Verifier/matrix-intrinsics-inline.ll
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index fe1854384e693..a59ec419e6a9a 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -6794,8 +6794,6 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
if (Stride) {
Check(Stride->getBitWidth() <= 64, "Stride bitwidth cannot exceed 64!",
IF);
- Check(Stride->getZExtValue() >= NumRows->getZExtValue(),
- "Stride must be greater or equal than the number of rows!", IF);
}
break;
diff --git a/llvm/test/Verifier/matrix-intrinsics-inline.ll b/llvm/test/Verifier/matrix-intrinsics-inline.ll
new file mode 100644
index 0000000000000..000ad6d5c51e4
--- /dev/null
+++ b/llvm/test/Verifier/matrix-intrinsics-inline.ll
@@ -0,0 +1,18 @@
+; RUN: opt -passes=inline -S %s 2>&1 | FileCheck %s
+; CHECK-NOT: LLVM ERROR: Broken module found, compilation aborted!
+define void @bar(i32 %stride) {
+ call void @llvm.matrix.column.major.store.v6f64.i32(<6 x double> zeroinitializer, ptr null, i32 %stride, i1 false, i32 3, i32 2)
+ ret void
+}
+
+; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: write)
+declare void @llvm.matrix.column.major.store.v6f64.i32(<6 x double>, ptr nocapture writeonly, i32, i1 immarg, i32 immarg, i32 immarg)
+
+define i64 @foo() {
+entry:
+ unreachable
+
+sink.call: ; No predecessors!
+ call void @bar(i32 0)
+ ret i64 0
+}
\ No newline at end of file
diff --git a/llvm/test/Verifier/matrix-intrinsics.ll b/llvm/test/Verifier/matrix-intrinsics.ll
index 43d1a79f0853f..00cee3271cb7c 100644
--- a/llvm/test/Verifier/matrix-intrinsics.ll
+++ b/llvm/test/Verifier/matrix-intrinsics.ll
@@ -99,24 +99,6 @@ define void @column.major_store_non_int_float_type(ptr %m, ptr %n, i64 %arg) {
ret void
}
-define <4 x float> @column.major_load_stride_too_small(ptr %m, i32 %arg) {
-;
-; CHECK-NEXT: Stride must be greater or equal than the number of rows!
-; CHECK-NEXT: ptr @llvm.matrix.column.major.load.v4f32.i64
-;
- %result.1 = call <4 x float> @llvm.matrix.column.major.load.v4f32.i64(ptr %m, i64 1, i1 false, i32 2, i32 2)
- ret <4 x float> %result.1
-}
-
-define void @column.major_store_stride_too_small(ptr %m, i64 %arg) {
-;
-; CHECK-NEXT: Stride must be greater or equal than the number of rows!
-; CHECK-NEXT: ptr @llvm.matrix.column.major.store.v4f32.i64
-;
- call void @llvm.matrix.column.major.store.v4f32.i64(<4 x float> zeroinitializer, ptr %m, i64 1, i1 false, i32 2, i32 2)
- ret void
-}
-
define <4 x float> @column.major_load_stride_i128(ptr %m, i32 %arg) {
; CHECK-NEXT: Stride bitwidth cannot exceed 64!
; CHECK-NEXT: ptr @llvm.matrix.column.major.load.v4f32.i128
More information about the llvm-commits
mailing list