This is an archive of the discontinued LLVM Phabricator instance.

Teach CorrelatedValuePropagation to mark adds as no wrap
ClosedPublic

Authored by apilipenko on Aug 2 2016, 6:47 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

apilipenko updated this revision to Diff 66465.Aug 2 2016, 6:47 AM
apilipenko retitled this revision from to Teach CorrelatedValuePropagation to mark adds as no wrap.
apilipenko updated this object.
apilipenko added a reviewer: sanjoy.
apilipenko added a subscriber: llvm-commits.
sanjoy accepted this revision.Aug 2 2016, 10:40 AM
sanjoy edited edge metadata.

lgtm modulo comments inline

lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
21 ↗(On Diff #66465)

Interesting that you had to add this. Doesn't LVI include this?

385 ↗(On Diff #66465)

Why AI as the variable name? I'd have gone with BO or something like that.

edit: I suppose you mean AddInst? In that case, I'd suggest calling it AddInst or AddOp. I've seen AI be normally used for alloca instructions.

409 ↗(On Diff #66465)

There is an optimization we can do here: we only need RRange if NUWRange (resp. NSWRange) is not empty. What do you think about changing RRange to an Optional<ConstantRange> and lazily initializing it? My intuition is that calling getConstantRange on a value that LVI hasn't seen before can be expensive (since it will have to do a CFG-walk).

test/Transforms/CorrelatedValuePropagation/add.ll
51 ↗(On Diff #66465)

For completeness, can you please add a few tests like @test3 and @test4 with signed integer min and signed integer max?

This revision is now accepted and ready to land.Aug 2 2016, 10:40 AM
apilipenko marked 3 inline comments as done.Aug 3 2016, 6:00 AM
apilipenko added inline comments.
lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
21 ↗(On Diff #66465)

LVI.h has forward declaration only

This revision was automatically updated to reflect the committed changes.