This is an archive of the discontinued LLVM Phabricator instance.

[LVI][CVP] Constrain values in with.overflow branches
ClosedPublic

Authored by nikic on Apr 13 2019, 5:27 AM.

Details

Summary

If a branch is conditional on extractvalue(op.with.overflow(%x, C), 1) then we can constrain the value of %x inside the branch based on makeGuaranteedNoWrapRegion(). We do this by extending the edge-value handling in LVI. This allows CVP to then fold comparisons against %x, as illustrated in the tests.

Diff Detail

Repository
rL LLVM

Event Timeline

nikic created this revision.Apr 13 2019, 5:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2019, 5:27 AM

Looks good, but someone familiar with LVI/CVP should review.

nikic updated this revision to Diff 195461.Apr 16 2019, 2:16 PM

Rebase over WithOverflowInst.

spatel accepted this revision.Apr 17 2019, 8:18 AM

I haven't looked at LVI much, but judging from the git log, nobody else has done that recently either.

The logic looks right, and the tests are great. LGTM.

llvm/lib/Analysis/LazyValueInfo.cpp
1140 ↗(On Diff #195461)

I see that the lower-case variable "isTrueDest" is carried over from existing code, but I think it should be changed to conform with the current guidelines and the formatting of other variables (unless the lowerCamelCase proposal is going forward...).

This revision is now accepted and ready to land.Apr 17 2019, 8:18 AM
This revision was automatically updated to reflect the committed changes.
nikic marked an inline comment as done.