This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] Infer no-self-wrap via constant ranges
ClosedPublic

Authored by reames on Mar 21 2023, 7:01 PM.

Details

Summary

Without this, pointer IVs in loops with small constant trip counts couldn't be proven no-self-wrap. This came up in a new LSR transform, but may also benefit other SCEV consumers as well.

Diff Detail

Event Timeline

reames created this revision.Mar 21 2023, 7:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 21 2023, 7:01 PM
reames requested review of this revision.Mar 21 2023, 7:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 21 2023, 7:01 PM
reames added inline comments.Mar 21 2023, 7:02 PM
llvm/test/Transforms/LoopVersioning/lcssa.ll
59

FYI, this gep is unused in the code before the change. No idea why the SCEV change causes the pause to realize it's dead, nor do I really care.

nikic added inline comments.Mar 22 2023, 2:23 AM
llvm/lib/Analysis/ScalarEvolution.cpp
4995

I think it would make more sense to use the constant max BECount here, rather than the range of the exact BECount. That should be strictly more powerful and is also more in line with how we infer nuw/nsw on affine addrecs.

reames updated this revision to Diff 507417.Mar 22 2023, 10:08 AM

Address review comment.

reames marked an inline comment as done.Mar 22 2023, 10:08 AM
nikic accepted this revision.Mar 22 2023, 10:42 AM

LGTM

llvm/lib/Analysis/ScalarEvolution.cpp
4995

const &

This revision is now accepted and ready to land.Mar 22 2023, 10:42 AM
This revision was landed with ongoing or failed builds.Mar 22 2023, 12:06 PM
This revision was automatically updated to reflect the committed changes.