This is an archive of the discontinued LLVM Phabricator instance.

[LVI] Exploit trivial range information from unknown RHS of icmp
AbandonedPublic

Authored by reames on Apr 26 2016, 2:42 PM.

Details

Summary

The primary motivation is in proving overflow facts. Particularly, overflow facts for loop induction variables. SCEV gets many of these cases today, but there's no reason LVI shouldn't get them to and having LVI able to catch the simple cases makes our pass order less fragile.

Note that this patch is only the analysis changes. A separate change will build on top of this to actually make "add" instructions as nsw/nuw.

Diff Detail

Event Timeline

reames updated this revision to Diff 55096.Apr 26 2016, 2:42 PM
reames retitled this revision from to [LVI] Exploit trivial range information from unknown RHS of icmp.
reames updated this object.
reames added reviewers: sanjoy, nicholas, hfinkel, regehr.
reames added a subscriber: llvm-commits.
sanjoy requested changes to this revision.Apr 26 2016, 11:51 PM
sanjoy edited edge metadata.
sanjoy added inline comments.
lib/Analysis/LazyValueInfo.cpp
1162

I wouldn't put all this logic here. Instead, it is easier to do:

ConstantRange RHSRange = FullRange;
ConstantRange LHSRange = makeAllowedRange(ICI->getPredicate(), RHSRange);
if (LHSRange is not full set)
  Result = LVILatticeVal::getRange(LHSRange);

Later you can improve precision by making RHSRange more precise.

This revision now requires changes to proceed.Apr 26 2016, 11:51 PM
reames added inline comments.May 4 2016, 12:12 PM
lib/Analysis/LazyValueInfo.cpp
1162

I really like this idea. I'm going to rewrite this patch when I get a chance and probably simplify a lot of other code nearby using the same trick.

reames abandoned this revision.Aug 24 2018, 3:04 PM

No longer needed, and extremely stale.

Tests landed as 340660. The code just above my diff was generalized as Sanjoy suggested in his review, so none of the dedicated code was needed.