This is an archive of the discontinued LLVM Phabricator instance.

[flang][hlfir] add hlfir.matmul_transpose operation
ClosedPublic

Authored by tblah on Mar 13 2023, 10:06 AM.

Details

Summary

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.

Diff Detail

Event Timeline

tblah created this revision.Mar 13 2023, 10:06 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
tblah requested review of this revision.Mar 13 2023, 10:06 AM
vzakhari accepted this revision.Mar 16 2023, 9:48 AM
This revision is now accepted and ready to land.Mar 16 2023, 9:48 AM
This revision was automatically updated to reflect the committed changes.