This is an archive of the discontinued LLVM Phabricator instance.

Use invariants in LazyValueInfo
ClosedPublic

Authored by hfinkel on Jul 14 2014, 11:46 PM.

Details

Reviewers
chandlerc
hfinkel
Summary

This patch teaches LazyValueInfo to use the invariant intrinsic. Like with the known-bits patch, this requires feeding a "context" instruction pointer through many functions. Aside from a little refactoring to reuse the logic that turns predicates into constant ranges in LVI, the only new code is that which can 'merge' the range from an invariant into that otherwise computed. There is also a small addition to JumpThreading so that it can have LVI use invariants in the same block as the comparison feeding a conditional branch.

With this patch, we can now simplify this as expected:
int foo(int a) {

__builtin_assume(a > 5);
if (a > 3) {
  bar();
  return 1;
}
return 0;

}

Diff Detail

Event Timeline

hfinkel updated this revision to Diff 11420.Jul 14 2014, 11:46 PM
hfinkel retitled this revision from to Use invariants in LazyValueInfo.
hfinkel updated this object.
hfinkel edited the test plan for this revision. (Show Details)
hfinkel added a reviewer: chandlerc.
hfinkel added a subscriber: Unknown Object (MLST).
chandlerc added inline comments.Jul 17 2014, 11:58 AM
lib/Analysis/LazyValueInfo.cpp
720–730

See comment on the other patch, it will end up applying here as well.

hfinkel updated this revision to Diff 11698.Jul 20 2014, 11:59 AM

Renamed to llvm.assume.

hfinkel updated this revision to Diff 11932.Jul 27 2014, 11:24 PM

Updated to use AssumptionTracker (this now also is must faster, owing to the lack of searching instruction users for @llvm.assume).

hfinkel accepted this revision.Sep 7 2014, 2:01 PM
hfinkel added a reviewer: hfinkel.

(will close)

This revision is now accepted and ready to land.Sep 7 2014, 2:01 PM
hfinkel closed this revision.Sep 7 2014, 2:02 PM

r217345.