This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] SimplifyDemandedUseBits - remove lshr node if we only demand known sign bit
ClosedPublic

Authored by RKSimon on Apr 5 2022, 4:53 AM.

Details

Summary

This is a lshr equivalent to D122340 - if we don't demand any of the additional sign bits introduced by the ashr, the lshr can be treated as an ashr and we can remove the shift entirely if we only demand an already known sign bit.

If people prefer, I can simplify the code further, but I figured it made sense to try to keep it similar to the ashr fold for comparison.

Another step towards PR21929

https://alive2.llvm.org/ce/z/6f3kjq

Diff Detail

Event Timeline

RKSimon created this revision.Apr 5 2022, 4:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 4:53 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
RKSimon requested review of this revision.Apr 5 2022, 4:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 4:54 AM
RKSimon updated this revision to Diff 421162.Apr 7 2022, 4:50 AM
RKSimon edited the summary of this revision. (Show Details)

We don't have to explicitly demand the signbit for this to work.

LGTM, thanks.

llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
556

I believe the same applies here.

lebedev.ri accepted this revision.Apr 7 2022, 5:43 AM
This revision is now accepted and ready to land.Apr 7 2022, 5:43 AM
This revision was landed with ongoing or failed builds.Apr 7 2022, 6:39 AM
This revision was automatically updated to reflect the committed changes.