Use LVI to prove that adds do not wrap. The change is motivated by https://llvm.org/bugs/show_bug.cgi?id=28620 bug and it's the first step to fix that problem.
Details
- Reviewers
sanjoy - Commits
- rGe171ea8a3319: Teach CorrelatedValuePropagation to mark adds as no wrap
rGa410d81f64a8: Teach CorrelatedValuePropagation to mark adds as no wrap
rG68cb947cc92d: Teach CorrelatedValuePropagation to mark adds as no wrap
rL278220: Teach CorrelatedValuePropagation to mark adds as no wrap
rL278107: Teach CorrelatedValuePropagation to mark adds as no wrap
rL277592: Teach CorrelatedValuePropagation to mark adds as no wrap
Diff Detail
Event Timeline
lgtm modulo comments inline
lib/Transforms/Scalar/CorrelatedValuePropagation.cpp | ||
---|---|---|
21 | Interesting that you had to add this. Doesn't LVI include this? | |
385 | 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 | 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 | For completeness, can you please add a few tests like @test3 and @test4 with signed integer min and signed integer max? |
lib/Transforms/Scalar/CorrelatedValuePropagation.cpp | ||
---|---|---|
21 | LVI.h has forward declaration only |
Interesting that you had to add this. Doesn't LVI include this?