This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner] make matching bit-hack form of usubsat more flexible
ClosedPublic

Authored by spatel on Oct 24 2021, 5:19 AM.

Details

Summary

(i8 X ^ 128) & (i8 X s>> 7) --> usubsat X, 128

As suggested in D112085, we can substitute 'xor' with 'add' in this pattern, and it is logically equivalent:
https://alive2.llvm.org/ce/z/eJtWWC

We canonicalize to 'xor' in IR, but SDAG does not do that (and it should not - https://llvm.org/PR52267 ), so it is possible to see either pattern in codegen. Note that 'sub' is a another potential pattern, but that is canonicalized to 'add' in DAGCombiner, so we don't need to worry about that variation.

Diff Detail

Event Timeline

spatel created this revision.Oct 24 2021, 5:19 AM
spatel requested review of this revision.Oct 24 2021, 5:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 24 2021, 5:19 AM
RKSimon accepted this revision.Oct 24 2021, 1:27 PM

LGTM (if we're confident this can appear in DAG)

This revision is now accepted and ready to land.Oct 24 2021, 1:27 PM
foad accepted this revision.Oct 25 2021, 1:08 AM

LGTM, thanks.

This revision was landed with ongoing or failed builds.Oct 25 2021, 6:02 AM
This revision was automatically updated to reflect the committed changes.