This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Reduce duplicate code for calling SimplifyDemandedBits.
ClosedPublic

Authored by craig.topper on Aug 18 2021, 12:43 PM.

Details

Summary

This encapsulates the APInt creation and worklist management into
a helper function.

To keep one common interface I've use Log2_32 in places that
previously created a mask by subtracting 1 from a power of 2.

Diff Detail

Event Timeline

craig.topper created this revision.Aug 18 2021, 12:43 PM
craig.topper requested review of this revision.Aug 18 2021, 12:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2021, 12:43 PM
Herald added a subscriber: MaskRay. · View Herald Transcript
craig.topper added inline comments.Aug 18 2021, 12:44 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
6088–6089

This comment was incorrect before

6098

As was this.

jrtc27 added inline comments.Aug 18 2021, 12:52 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
5970

Do you intend to call this from other functions too? If not, you could make it a lambda and avoid having to pass N, DCI and TLI.

Use a lambda

luismarques accepted this revision.Aug 19 2021, 1:19 AM

LGTM.

llvm/lib/Target/RISCV/RISCVISelLowering.cpp
5974

Nit: it's not really important, and to some extent a matter of style, but things like "Helper" aren't very semantically descriptive. IMO it's best to, when possible, say instead in what way it's helping, e.g. SimplifyOpDemandedLowBits.

This revision is now accepted and ready to land.Aug 19 2021, 1:19 AM
craig.topper added inline comments.Aug 19 2021, 7:31 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
5974

I guess I was focusing on the work list management when I called it Helper. That made it different than just a version of SimplifyDemandedBits that takes a bit count instead of a mask.