Skip to content

Commit 8bfaff3

Browse files
committed
[Matrix][IR] Cap stride bitwidth at 64
1 parent a42546e commit 8bfaff3

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

llvm/lib/IR/Verifier.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6479,9 +6479,12 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
64796479
NumRows->getZExtValue() * NumColumns->getZExtValue(),
64806480
"Result of a matrix operation does not fit in the returned vector!");
64816481

6482-
if (Stride)
6482+
if (Stride) {
6483+
Check(Stride->getBitWidth() <= 64, "Stride bitwidth cannot exceed 64!",
6484+
IF);
64836485
Check(Stride->getZExtValue() >= NumRows->getZExtValue(),
64846486
"Stride must be greater or equal than the number of rows!", IF);
6487+
}
64856488

64866489
break;
64876490
}

llvm/test/Verifier/matrix-intrinsics.ll

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
1+
; RUN: not opt -S %s 2>&1 | FileCheck %s
22

33
define <4 x float> @transpose(<4 x float> %m, i32 %arg) {
4-
; CHECK: assembly parsed, but does not verify as correct!
5-
; CHECK-NEXT: Result of a matrix operation does not fit in the returned vector!
4+
; CHECK: Result of a matrix operation does not fit in the returned vector!
65
; CHECK-NEXT: Result of a matrix operation does not fit in the returned vector!
76
; CHECK-NEXT: Result of a matrix operation does not fit in the returned vector!
87
; CHECK-NEXT: immarg operand has non-immediate parameter
@@ -118,16 +117,34 @@ define void @column.major_store_stride_too_small(ptr %m, i64 %arg) {
118117
ret void
119118
}
120119

120+
define <4 x float> @column.major_load_stride_i128(ptr %m, i32 %arg) {
121+
; CHECK-NEXT: Stride bitwidth cannot exceed 64!
122+
; CHECK-NEXT: ptr @llvm.matrix.column.major.load.v4f32.i128
123+
%result.1 = call <4 x float> @llvm.matrix.column.major.load.v4f32.i128(ptr %m, i128 u0x10000000000000000, i1 false, i32 2, i32 2)
124+
ret <4 x float> %result.1
125+
}
126+
127+
define void @column.major_store_stride_i128(ptr %m, i64 %arg) {
128+
; CHECK-NEXT: Stride bitwidth cannot exceed 64!
129+
; CHECK-NEXT: ptr @llvm.matrix.column.major.store.v4f32.i128
130+
call void @llvm.matrix.column.major.store.v4f32.i128(<4 x float> zeroinitializer, ptr %m, i128 u0x10000000000000000, i1 false, i32 2, i32 2)
131+
ret void
132+
}
133+
121134
declare <4 x i32> @llvm.matrix.column.major.load.v4i32.i64(ptr, i64, i1, i32, i32)
122135
declare <4 x float> @llvm.matrix.column.major.load.v4f32.p0(ptr, i64, i1, i32, i32)
123136
declare <4 x float> @llvm.matrix.column.major.load.v4f32.i64(ptr, i64, i1, i32, i32)
124137
declare <6 x float> @llvm.matrix.column.major.load.v6f32.i64(ptr, i64, i1, i32, i32)
138+
declare <6 x float> @llvm.matrix.column.major.load.v6f32.i8(ptr, i8, i1, i32, i32)
139+
declare <6 x float> @llvm.matrix.column.major.load.v6f32.i128(ptr, i28, i1, i32, i32)
125140

126141
declare void @llvm.matrix.column.major.store.v4f32.i64(<4 x float>, ptr, i64, i1, i32, i32)
127142
declare void @llvm.matrix.column.major.store.v6f32.i64(<6 x float>, ptr, i64, i1, i32, i32)
128143
declare void @llvm.matrix.column.major.store.v4i32.vi32(<4 x i32>, ptr, i64, i1, i32, i32)
129144
declare void @llvm.matrix.column.major.store.v4f32.p0(<4 x float>, ptr, i64, i1, i32, i32)
130145
declare void @llvm.matrix.column.major.store.v4p0.i64(<4 x ptr>, ptr, i64, i1, i32, i32)
146+
declare void @llvm.matrix.column.major.store.v4p0.i8(<4 x ptr>, ptr, i8, i1, i32, i32)
147+
declare void @llvm.matrix.column.major.store.v4p0.i128(<4 x ptr>, ptr, i128, i1, i32, i32)
131148

132149
declare <4 x i32> @llvm.matrix.transpose.v4i32.v4f32(<4 x float>, i32, i32)
133150
declare <4 x float> @llvm.matrix.transpose.v4f32(<4 x float>, i32, i32)

0 commit comments

Comments
 (0)