This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] Fold and/or using implied conditions
ClosedPublic

Authored by nikic on May 13 2022, 3:30 AM.

Details

Summary

This adds two conjugated folds:

If A and B are icmps themselves, we will usually fold this through other logic already (though the tests show a couple additional cases we previously missed). However, isImpliedCond() also supports A being of the form X & Y, which allows us to handle cases like (X & Y) | B where X implies B. This addresses the regression from D125398.

Something that notably doesn't work yet is the (X | Y) & B case. This is due to an asymmetry in the isImpliedCondition() implementation that will have to be addressed separately.

Diff Detail

Event Timeline

nikic created this revision.May 13 2022, 3:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2022, 3:30 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
nikic requested review of this revision.May 13 2022, 3:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2022, 3:30 AM
fhahn accepted this revision.May 13 2022, 5:05 AM

LGTM, thanks!

llvm/lib/Analysis/InstructionSimplify.cpp
2226

nit: might be good to have // A&B -> B where B implies A?

Not sure about the comments using A/B while the code using Op0/Op1. Might be good to keep things consistent, but A/B` seems nicer

This revision is now accepted and ready to land.May 13 2022, 5:05 AM
This revision was landed with ongoing or failed builds.May 13 2022, 6:09 AM
This revision was automatically updated to reflect the committed changes.
nikic marked an inline comment as done.