This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] Also strengthen flags for post-increment.
AcceptedPublic

Authored by fhahn on Mar 6 2023, 8:52 AM.

Details

Summary

Also strengthen the flags for the post-increment SCEV, as suggested by
@mkazantsev.

Depends on D144050.

Diff Detail

Event Timeline

fhahn created this revision.Mar 6 2023, 8:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2023, 8:52 AM
fhahn requested review of this revision.Mar 6 2023, 8:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2023, 8:52 AM
mkazantsev accepted this revision.Mar 6 2023, 8:56 PM
mkazantsev added inline comments.
llvm/test/Analysis/ScalarEvolution/solve-quadratic-i1.ll
12

It's amazing how pessimistic we are here. Everything is going through nsw, but we still manage to cross upper bound of signed range. Sigh...

This revision is now accepted and ready to land.Mar 6 2023, 8:56 PM
nikic added inline comments.Mar 7 2023, 12:15 AM
llvm/test/Analysis/ScalarEvolution/solve-quadratic-i1.ll
12

It's a half-open range, so this doesn't actually cross the upper bound.

nikic added inline comments.Mar 7 2023, 12:20 AM
llvm/lib/Analysis/ScalarEvolution.cpp
5673

It's not really obvious to me why this is correct. Can't the extra addition of the post-inc addrec overflow, even if the pre-inc addrec can't? I believe the current reasoning for setting flags on the post-inc addrec is specifically about nowrap flags present in IR that would result in UB if violated. I don't think this would hold up for flags inferred from the pre-inc addrec range.

fhahn marked an inline comment as done.Apr 17 2023, 2:51 AM
fhahn added inline comments.
llvm/lib/Analysis/ScalarEvolution.cpp
5673

It's also not really obvious to me as mentioned here: https://reviews.llvm.org/D144050#inline-1404195