This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Prevent constant hoisting for (and (shl X, C), mask<<C)
ClosedPublic

Authored by craig.topper on Nov 17 2022, 10:01 PM.

Details

Summary

If the immediate is a shifted mask, we will use a pair of shifts
and never materialize the immediate. Consider the immediate free.

Diff Detail

Event Timeline

craig.topper created this revision.Nov 17 2022, 10:01 PM
craig.topper requested review of this revision.Nov 17 2022, 10:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 17 2022, 10:01 PM
luismarques accepted this revision.Nov 21 2022, 2:25 AM

LGTM.

llvm/test/Transforms/ConstantHoisting/RISCV/immediates.ll
85

Nit: having a comment here with the rationale from the summary ("If the immediate is a shifted mask, we will use a pair of shifts and never materialize the immediate") would be convenient, since without the assembly code that might not be obvious.

This revision is now accepted and ready to land.Nov 21 2022, 2:25 AM
reames accepted this revision.Nov 21 2022, 8:36 AM

LGTM as well w/the same comment on adding comments. I'd also encourage a comment on the helper routine which describes the pattern you're matching and why that makes the immediate free.