This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] Generalize implication when signedness of FoundPred doesn't matter
ClosedPublic

Authored by mkazantsev on Sep 17 2021, 3:42 AM.

Details

Summary

The implication logic for two values that are both negative or non-negative
says that it doesn't matter whether their predicate is signed and unsigned it,
but only flips unsigned into signed for further inference. This patch adds support
for flipping a signed predicate into unsigned.

Diff Detail

Event Timeline

mkazantsev created this revision.Sep 17 2021, 3:42 AM
mkazantsev requested review of this revision.Sep 17 2021, 3:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 17 2021, 3:42 AM
mkazantsev edited the summary of this revision. (Show Details)Sep 19 2021, 10:13 PM
nikic accepted this revision.Sep 20 2021, 12:20 PM

LGTM

llvm/lib/Analysis/ScalarEvolution.cpp
10711

You should be able to simply this to CmpInst::isRelational(P2) && P1 == CmpInst::getFlippedSignednessPredicate(P2).

This revision is now accepted and ready to land.Sep 20 2021, 12:20 PM
mkazantsev added inline comments.Sep 20 2021, 9:06 PM
llvm/lib/Analysis/ScalarEvolution.cpp
10711

That's a good point, thanks!