This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] remove constant by inverting compare + logic (PR27105)
ClosedPublic

Authored by spatel on Apr 6 2016, 1:17 PM.

Details

Summary

This is a fix for PR27105:
https://llvm.org/bugs/show_bug.cgi?id=27105

We can check if all bits outside of a constant mask are set with a single constant.

As noted in the bug report, although this form should be considered the canonical IR, backends may want to transform this into an 'andn' / 'andc' comparison against zero because that could be a single machine instruction.

Diff Detail

Repository
rL LLVM

Event Timeline

spatel updated this revision to Diff 52844.Apr 6 2016, 1:17 PM
spatel retitled this revision from to [InstCombine] remove constant by inverting compare + logic (PR27105).
spatel updated this object.
spatel added reviewers: hfinkel, majnemer, nlopes, amehsan.
spatel added a subscriber: llvm-commits.
hfinkel accepted this revision.Apr 13 2016, 5:42 PM
hfinkel edited edge metadata.

I'm not sure how much reducing the number of independent constants matters for canonicalization, but this form also looks more natural for extracting known bits by later optimizations. LGTM.

This revision is now accepted and ready to land.Apr 13 2016, 5:42 PM
This revision was automatically updated to reflect the committed changes.