I am going through this llvm (https://discourse.llvm.org/t/rfc-first-class-matrix-type/50021 ). This IR looks perfectly nice to me. As a beginner, I only want to ask is there any way to produce exactly same IR
%0 = load <4 x 4 x float>, <4 x 4 x float>* %a, align 16
%1 = load <4 x 4 x float>, <4 x 4 x float>* %b, align 16
%2 = call <4 x 4 x float> @llvm.matrix.multiply.m4_4f32.m4_4f32.m4_4f32(<4 x 4 x float> %0, <4 x 4 x float> %1)
store <4 x 4 x float> %2, <4 x 4 x float>* %c, align 16
from current llvm(release/16.x) using some passes. If the answer is no, so how to proceed to support this type of IR in both clang and llvm?
fhahn
February 3, 2023, 11:24am
2
The current matrix support lowers matrixes as flat vector, so instead of <4 x 4 x float>
it uses <16 x float>
. See Compiler Explorer for an example
1 Like
pegasus
February 3, 2023, 12:15pm
3
Thank you for the clarification.
By using the flag -print-before=lower-matrix-intrinsics
, we are able to dump the instructions,
however, could we generate the valid .ll file of the same, where we can iterate through each of the instructions?
Also, if I want to store the matrix value like similar to the statement written below, how to do it?
matrix_ty A = {{1,2},{3,4}}; // similar to this statement, but with correct syntax
fhahn
February 3, 2023, 12:37pm
4
pegasus:
By using the flag -print-before=lower-matrix-intrinsics
, we are able to dump the instructions,
If you want to dump a module, you can use -mllvm -print-module-scope
pegasus:
Also, if I want to store the matrix value like similar to the statement written below, how to do it?
That’s not supported at the moment, please see Matrix Types — Clang 17.0.0git documentation for the supported operations.
1 Like