[cfe-dev] matrix type conversion

Sjoerd Meijer via cfe-dev cfe-dev at lists.llvm.org
Wed Aug 12 04:25:10 PDT 2020

Hi Florian (+cfe-dev for visibilty),

I was playing a little bit with Clang matrix language extension and and wanted to check with you to see if I am not missing something about the matrix type conversion. The draft spec says:

"A value of matrix type can be converted to another matrix type if the number of rows and columns are the same and the value’s elements can be converted to the element type of the result type. "

I have tried a different variants of this:

    typedef char m2x8_t __attribute__((matrix_type(2, 8)));
    typedef char m8x2_t __attribute__((matrix_type(8, 2)));
    typedef char m2x2_char_t __attribute__((matrix_type(2, 2)));
    typedef int  m2x2_int_t  __attribute__((matrix_type(2, 2)));

    m2x2_int_t f(m2x8_t a, m8x2_t b) {
      return static_cast<m2x2_int_t>(a *b);

but am getting errors that this conversion is not allowed. Unless I am doing something very silly here, I am guessing that this because the matrix extension is work in progress?

The draft spec also says that implicit conversions don't apply, but that would perhaps be convenient? But I haven't given this any thoughts yet though if that could be problematic.

Moving on a bit to lowering this to te matrix multiply intrinsics. I think it would be convenient if the matrix multiply can accumulate in a wider type (because that's what some instructions do). While there are probably different approaches possible, the llvm intrinsic has the vector type for the return value and its arguments:

vectorty @llvm.matrix.multiply.*(vectorty %A, vectorty %B, ...)

 So perhaps we can relax this?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200812/d618c0be/attachment.html>

More information about the cfe-dev mailing list