[SCEV] Fix isLoopEntryGuardedByCond usage
ScalarEvolution::isKnownPredicate invokes isLoopEntryGuardedByCond without check
that SCEV is available at entry point of the loop. It is incorrect and fixed by patch.
To bugs additionally fixed:
assert is moved after the check whether loop is not a nullptr.
Usage of isLoopEntryGuardedByCond in ScalarEvolution::isImpliedCondOperandsViaNoOverflow
is guarded by isAvailableAtLoopEntry.
I still suspect (but am not sure) that this is too "deep" in the call stack to bail out like this -- I suspect the bug is somewhere up in a caller since the query {A,+,B}<L> pred <thing not available on L's entry> seems nonsensical.
I want to throw this in a debugger and take a look, but the attached test case does not fail for me on rL324202 (with opt -indvars inner-loop.ll). Can you please verify that the test case fails for you without the SCEV changes?