If we cannot prove that the check is trivially true, but can prove that it either
fails on the 1st iteration or never fails, we can replace it with first iteration check.
Details
Diff Detail
Event Timeline
Just a stylistic comment. You can have the InvariantCond as a struct with the fields: InvariantPred, InvariantLHS, InvariantRHS. I think this will make code more readable (for example, use the struct in ReplaceInvariantCond(ExitingBB, InvariantCond).
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | ||
---|---|---|
2359 | I maybe missing something. Where are we checking the "never fails in any iteration other than the first" ? | |
2437 | Nit: ReplaceWithInvariantCond. |
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | ||
---|---|---|
2359 | SE->isLoopInvariantExitCondDuringFirstIterations ? |
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | ||
---|---|---|
2359 | Yes, inside of isLoopInvariantExitCondDuringFirstIterations we effectively check that comparison against IV may be replaced with comparison against start. |
(InvariantPred, InvariantLHS, InvariantRHS) API is used in SCEV. I will follow-up with refactoring changing it whevever it is used.
I maybe missing something. Where are we checking the "never fails in any iteration other than the first" ?