This is an archive of the discontinued LLVM Phabricator instance.

[flang][hlfir] add matmul canonicalizer
ClosedPublic

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

Details

Summary

hlfir.matmul_transpose will be lowered to a new runtime call.

A canonicalizer was chosen because

  • Alternative: a new pass for rewriting chained intrinsics - this would add a lot of unnecessary boilerplate.
  • Alternative: including this in the HLFIR Intrinsic Lowering pass - I wanted to separate these two concerns: not adding a second purpose complicating the intrinsic lowering pass.

With this change, the MLIR built-in canonicalization pass should be run
before the HLFIR Intrinsic Lowering pass.

Depends on D145504, D145957

Diff Detail

Event Timeline

tblah created this revision.Mar 13 2023, 10:08 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMar 13 2023, 10:08 AM
tblah requested review of this revision.Mar 13 2023, 10:08 AM
clementval accepted this revision.Mar 14 2023, 2:56 AM

I think it makes sense to do this as a canonicalization pattern.

This revision is now accepted and ready to land.Mar 14 2023, 2:56 AM
vzakhari added inline comments.Mar 15 2023, 7:54 PM
flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
653

There is got to be some verification that the two uses are exactly hlfir.matmul and hlfir.destroy, otherwise, the transformation will silently produce incorrect code in case the HLFIR contract changes at some point.

tblah updated this revision to Diff 505748.Mar 16 2023, 3:07 AM

Thanks for your comment.

Updated to check that the uses are exactly 'hlfir.matmul' and 'hlfir.destroy'.

vzakhari accepted this revision.Mar 16 2023, 9:39 AM

Thank you for the update!

This revision was automatically updated to reflect the committed changes.