This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] Remove and(x.c) if all the known bits are handled just by x or c
AbandonedPublic

Authored by RKSimon on Aug 16 2022, 4:26 AM.

Details

Reviewers
spatel
nikic
Summary

This is a cut down version of what SimplifyMultipleUseDemandedBits tries to - if the RHS is a constant mask then see if the LHS known bits means that result bits are all known.

I wasn't sure how much we should be calling computeKnownBits in a lighter pass such as InstSimplify so I didn't generalise this to call computeKnownBits for a non-constant RHS as well, but we could very easily in the future, we could even consider moving InstCombinerImpl::SimplifyMultipleUseDemandedBits into InstSimplify?

Noticed as @spatel wondered if extending D131838 test coverage would be easier in InstSimplify

Diff Detail

Event Timeline

RKSimon created this revision.Aug 16 2022, 4:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 16 2022, 4:26 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
RKSimon requested review of this revision.Aug 16 2022, 4:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 16 2022, 4:26 AM

I tried a compile-time-tracker experiment with this patch applied, and it shows a slight, but noticeable compile-time hit, so I'd say it's not worth doing for a theoretical win:
https://llvm-compile-time-tracker.com/?config=NewPM-O3&stat=instructions&remote=rotateright

RKSimon abandoned this revision.Aug 16 2022, 7:13 AM

I tried a compile-time-tracker experiment with this patch applied, and it shows a slight, but noticeable compile-time hit, so I'd say it's not worth doing for a theoretical win:
https://llvm-compile-time-tracker.com/?config=NewPM-O3&stat=instructions&remote=rotateright

Agreed - I'll abandon this for now.