[flang][hlfir] add hlfir.matmul_transpose operation
authorTom Eccles <tom.eccles@arm.com>
Fri, 17 Mar 2023 09:26:27 +0000 (09:26 +0000)
committerTom Eccles <tom.eccles@arm.com>
Fri, 17 Mar 2023 09:30:04 +0000 (09:30 +0000)
commit49bd444fc3617a140ef67047d756c4d652a2a835
tree3aec4dc8b8c7fb031259934db3ca870787a60597
parente29d1d0f80b0ee39115f68da61ca1417f315a322
[flang][hlfir] add hlfir.matmul_transpose operation

This operation will be used to transform MATMUL(TRANSPOSE(a), b). The
transformation will go in the following stages:
        1. Lowering to hlfir.transpose and hlfir.matmul
        2. Canonicalise to hlfir.matmul_transpose
        3. hlfir.matmul_transpose will be lowered to FIR as a new runtime
          library call

Step 2 (and this operation) are included for consistency with the other
hlfir intrinsic operations and to avoid mixing concerns in the intrinsic
lowering pass.

In step 3, a new runtime library call is used because this operation is
most easily implemented in one go (the transposed indexing actually
makes the indexing simpler than for a normal matrix multiplication). In
the long run, it is intended that HLFIR will allow the same buffer
to be shared between different runtime calls without temporary
allocations, but in this specific case we can do even better than that
with a dedicated implementation.

This should speed up galgel from SPEC2000 (but this hadn't been tested
yet). The optimization was implemented in Classic Flang.

Reviewed By: vzakhari

Differential Revision: https://reviews.llvm.org/D145957
flang/docs/HighLevelFIR.md
flang/include/flang/Optimizer/HLFIR/HLFIROps.td
flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
flang/test/HLFIR/invalid.fir
flang/test/HLFIR/matmul_transpose.fir [new file with mode: 0644]