This patch teaches computeConstantDifference handle calculation of constant
difference between (X + C1) and (X + C2) which is (C2 - C1).
Details
Diff Detail
Event Timeline
lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
9901 | This is incorrect. LHS and FoundLHS can have different types. I will fix this before merging this patch. |
lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
9551 | Also incorrect, because types of LHS and FoundLHS doesn't have to match. |
lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
9496 | I'd much rather not put all of this (albeit non-recursive) work here when it is possible to easily extend the existing code to handle your pattern. | |
9551 | Do you have a test case for this? ScalarEvolution::isImpliedCond should be zero/sign extending LHS/FoundLHS to make both of them have the same type before calling ScalarEvolution::isImpliedCondOperands. If there are other callsites that don't respect this invariant they should zero/sign extend as well. |
lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
9551 | Never mind, it seems that I saw this failing due to a bug in another patch I'm working on. False alarm, most likely. |
lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
9496 | Do we really want to add every easy pattern we find here in future just because it is easy? It looks counter-general. And we don't know how many other relatively simple cases we do not handle. |
lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
9496 |
If this function starts growing too much with a lot of ad-hoc strategies, we need some other way to handle the kinds of cases you're trying to handle (perhaps by making code higher up the stack smarter). But for now you should be able to easily handle LHS = {X + C1,+,step}, RHS = {X + C2,+,step}, |
test/Transforms/IndVarSimplify/promote-iv-to-eliminate-casts.ll | ||
---|---|---|
105 | IIUC, this test uses the logic in computeConstantDifference for (X + C2) - (X + C1)`. |
test/Transforms/IndVarSimplify/promote-iv-to-eliminate-casts.ll | ||
---|---|---|
105 | I haven't added these cases for X - (X + C1), they were here before, I've just refactored and commented the code slightly. :) But OK, I will add some tests on these situations. |
I'd much rather not put all of this (albeit non-recursive) work here when it is possible to easily extend the existing code to handle your pattern.