This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Optimize some special mul operation in Zba extension
AbandonedPublic

Authored by Jimerlife on Jan 13 2022, 6:35 PM.

Details

Summary

Optimized (mul x, 27), (mul x, 45), (mul x, 81) in previous patterns may has some problem. Cannot generate two same assembly SH3ADD x, x after isel, so I removed those groups patterns and add some mul optimization which referred to before optimization.

Before:
(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))

My Add:
(mul x, 23) -> (SH2ADD (SH2ADD x, x), (SH1ADD x, x))
(mul x, 43) -> (SH3ADD (SH2ADD x, x), (SH1ADD x, x))
(mul x, 39) -> (SH2ADD (SH3ADD x, x), (SH1ADD x, x))
(mul x, 75) -> (SH3ADD (SH3ADD x, x), (SH1ADD x, x))
(mul x, 77) -> (SH3ADD (SH3ADD x, x), (SH2ADD x, x))

Diff Detail

Event Timeline

Jimerlife created this revision.Jan 13 2022, 6:35 PM
Jimerlife requested review of this revision.Jan 13 2022, 6:35 PM

I don't understand the problem with 27, 45, and 81. There shouldn't be a problem generating two same instructions. X86 does it in multiple places. Can you explain more?

The new patterns with 3 instructions might not be profitable for my company's CPUs.

Jimerlife accepted this revision.Jan 13 2022, 7:21 PM

There is no problem with 27, 45, 81. I will abandon this revision.

This revision is now accepted and ready to land.Jan 13 2022, 7:21 PM
Jimerlife abandoned this revision.Jan 13 2022, 7:21 PM