This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Add A+B+1 and A-B-1 macro fusion for Ampere1A
ClosedPublic

Authored by philipp.tomsich on Jan 24 2023, 12:54 PM.

Details

Summary

The Ampere1A core supports a new fusion pattern that optimises the
case of A+B+1 and A-B-1. Add support.

Depends on D142396

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJan 24 2023, 12:54 PM
philipp.tomsich requested review of this revision.Jan 24 2023, 12:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 24 2023, 12:54 PM

Can you add some tests. Possibly with a mir test?

llvm/lib/Target/AArch64/AArch64.td
293

HasFuseeAddSub2RegAndConstOne -> HasFuseAddSub2RegAndConstOne

1313–1314

These look unrelated to the macro fusion.

llvm/lib/Target/AArch64/AArch64MacroFusion.cpp
382

It may be useful to add brackets for clarity, if it works this way: "(A + B) + 1" or "(A - B) - 1"
Do you know if the first is commutative?

385

Capitalize Polarity

Matt added a subscriber: Matt.Jan 25 2023, 8:55 AM
  • added MIR test case
  • rewrote idiom-matcher: + fixes issues with the "subtract" case + recognizes ADD[XW]rs
philipp.tomsich marked an inline comment as done.
  • clarify comment
philipp.tomsich marked an inline comment as done.Jan 25 2023, 4:26 PM
dmgreen added inline comments.Jan 26 2023, 8:41 AM
llvm/lib/Target/AArch64/AArch64.td
1313–1314

Should these be part of another patch?

llvm/lib/Target/AArch64/AArch64.td
1313–1314

Looks like I picked these up by accident. Will split them off again.
Sorry, the tooling with 'arc' is (still) killing me as I am used to patman.

dmgreen accepted this revision.Jan 29 2023, 2:31 AM

If you remove the extra FeatureSB changes, then this LGTM

llvm/lib/Target/AArch64/AArch64.td
293

Remove this extra e too.

llvm/test/CodeGen/AArch64/macro-fusion-addsub-2reg-const1.mir
2

It may be worth adding more tests for more combos of instructions.

This revision is now accepted and ready to land.Jan 29 2023, 2:31 AM

Addresses review comments (so the landed version is the same as here).

This revision was landed with ongoing or failed builds.Jan 29 2023, 8:27 AM
This revision was automatically updated to reflect the committed changes.
llvm/test/CodeGen/AArch64/macro-fusion-addsub-2reg-const1.mir
2

Agreed. We'll defer this to a later change, and I'll land this with the single test.