I am investigating a difference in code generation between release and assert builds of llvm.
The culprit is IndVarSimplify that comes up with different behavior on the same input:
in the assertion build, it does do an extra 'INDVARS: Rewriting loop exit condition'
After digging around, it seems that following change is the culprit:
This is definitely not expected. `getBackedgeTakenCount` caches some
intermediate results (e.g. SCEV normalized forms) and its not unheard
of that these influence other computations. However, the results
should be the same whether its from the cache of freshly computed. It
is also possible that some pass does not correctly invalidate a
Could you file a bug?
Filed as 'Release and Assert version of IndVarSimplify produce different code':
I wish this was entirely true. The are known issues in SCEV where the order in which queries are performed can influence which set of results get cached. As such, you can get two equally valid and correct answers with different levels of precision by simply changing the order in which you ask queries. I suspect that's what is going on here. I agree that it's very unfortunate, but I don't think it's easy to fix either.