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 29 2021, 6:08 AM.

Details

Summary

This patch does the following optimization of mul with a constant.

(mul x, 11) -> (SH1ADD (SH2ADD x, x), x)
(mul x, 19) -> (SH1ADD (SH3ADD x, x), x)
(mul x, 13) -> (SH2ADD (SH1ADD x, x), x)
(mul x, 21) -> (SH2ADD (SH2ADD x, x), x)
(mul x, 37) -> (SH2ADD (SH3ADD x, x), x)
(mul x, 25) -> (SH3ADD (SH1ADD x, x), x)
(mul x, 41) -> (SH3ADD (SH2ADD x, x), x)
(mul x, 73) -> (SH3ADD (SH3ADD x, x), x)
(mul x, 27) -> (SH1ADD (SH3ADD x, x), (SH3ADD x, x))
(mul x, 45) -> (SH2ADD (SH3ADD x, x), (SH3ADD x, x))
(mul x, 81) -> (SH3ADD (SH3ADD x, x), (SH3ADD x, x))

Diff Detail

Event Timeline

benshi001 created this revision.Jul 29 2021, 6:08 AM
benshi001 requested review of this revision.Jul 29 2021, 6:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 29 2021, 6:08 AM
benshi001 updated this revision to Diff 362745.Jul 29 2021, 6:12 AM
benshi001 edited the summary of this revision. (Show Details)

This is the last patch for optimization with SHxADD, all similar optimization in x86 are ported to RISCV.

This revision is now accepted and ready to land.Jul 29 2021, 9:05 AM
This revision was automatically updated to reflect the committed changes.