This is an archive of the discontinued LLVM Phabricator instance.

[LoongArch] Optimize multiplication with immediates
ClosedPublic

Authored by benshi001 on Apr 6 2023, 2:20 AM.

Details

Summary

Optimize (mul x, imm) to (ADD (SLLI x, s0), (SLLI x, s1)) or
(SUB (SLLI x, s0), (SLLI x, s1)) if possible.

Diff Detail

Event Timeline

benshi001 created this revision.Apr 6 2023, 2:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2023, 2:20 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
benshi001 requested review of this revision.Apr 6 2023, 2:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2023, 2:20 AM
benshi001 updated this revision to Diff 511370.Apr 6 2023, 4:43 AM

The changes LGTM except a nit in comments. Thanks.

llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
3169

Seems this condition only applies to ADD but no SUB. For example, in below test, 65280 is 0xff00 which has 8 consecutive set bits.

benshi001 updated this revision to Diff 512643.Apr 11 2023, 8:04 PM
benshi001 edited the summary of this revision. (Show Details)
benshi001 marked an inline comment as done.
benshi001 added inline comments.
llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
3169

Thanks. Fixed.

benshi001 marked an inline comment as done.Apr 11 2023, 8:05 PM
SixWeining accepted this revision.Apr 11 2023, 8:06 PM

Thanks.

This revision is now accepted and ready to land.Apr 11 2023, 8:06 PM
This revision was landed with ongoing or failed builds.Apr 11 2023, 9:00 PM
This revision was automatically updated to reflect the committed changes.