This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombine] Fold A + (B & ~A) to A | B
ClosedPublic

Authored by nikic on May 2 2022, 7:29 AM.

Details

Summary

This is the DAGCombine companion fold for the InstCombine version in D124763. This time we only need to handle A + (B & ~A) to A | B (https://alive2.llvm.org/ce/z/N5fWZ9), because there's only one canonical form.

The reason why this needs to be a DAGCombine is that in the motivating case the add is actually a getelementptr, which only gets converted into an add on the DAG level. This patch is not quite sufficient to handle the getelementptr case yet, because of an interfering demanded bits simplification.

Diff Detail

Event Timeline

nikic created this revision.May 2 2022, 7:29 AM
nikic requested review of this revision.May 2 2022, 7:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 2 2022, 7:29 AM
RKSimon added inline comments.May 2 2022, 10:12 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
2842 ↗(On Diff #426415)

Similar question to D124763 - can this be done in SelectionDAG::haveNoCommonBitsSet?

nikic updated this revision to Diff 426630.May 3 2022, 3:33 AM

Implement in haveNoCommonBitsSet().

RKSimon accepted this revision.May 3 2022, 6:16 AM

LGTM - cheers

This revision is now accepted and ready to land.May 3 2022, 6:16 AM
This revision was landed with ongoing or failed builds.May 3 2022, 6:47 AM
This revision was automatically updated to reflect the committed changes.