This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Disable constant hoisting for multiply by negated power of 2.
ClosedPublic

Authored by craig.topper on Jul 18 2022, 3:37 PM.

Details

Summary

A mul by a negated power of 2 is a slli followed by neg. This doesn't
require any constant materialization and may be lower latency than mul.
The neg may also be foldable into other arithmetic.

Diff Detail

Event Timeline

craig.topper created this revision.Jul 18 2022, 3:37 PM
Herald added a project: Restricted Project. · View Herald Transcript
craig.topper requested review of this revision.Jul 18 2022, 3:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2022, 3:37 PM
reames accepted this revision.Jul 27 2022, 7:57 AM

LGTM

However, I'll note the code structure here is non-obvious. When I see code talking about immediate cost, I don't expect that to be highly specific to hoisting. I expect it to instead relate to materialization cost. And yet, that doesn't appear to be what the existing code in this method does.

This revision is now accepted and ready to land.Jul 27 2022, 7:57 AM
This revision was landed with ongoing or failed builds.Jul 27 2022, 9:38 AM
This revision was automatically updated to reflect the committed changes.