This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Optimize mul in the zba extension with SH*ADD
ClosedPublic

Authored by benshi001 on Jul 23 2021, 4:16 AM.

Details

Summary

This patch makes the following optimization, if the
immediate multiplier is not a simm12.

(mul x, (power_of_2 + 2)) => (SH1ADD x, (SLLI x, bits))
(mul x, (power_of_2 + 4)) => (SH2ADD x, (SLLI x, bits))
(mul x, (power_of_2 + 8)) => (SH3ADD x, (SLLI x, bits))

Diff Detail

Event Timeline

benshi001 created this revision.Jul 23 2021, 4:16 AM
benshi001 requested review of this revision.Jul 23 2021, 4:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2021, 4:16 AM

It is obvious a win if the immediate is non-simm12, but not sure for simm12, so I leave that unchanged.

Ping ...

I saw the similar optimization on x86, and think it will also benefit riscv.

This revision is now accepted and ready to land.Jul 28 2021, 5:41 PM
This revision was landed with ongoing or failed builds.Jul 28 2021, 6:47 PM
This revision was automatically updated to reflect the committed changes.