Before this patch, In SimplifyICmpOperands, the comparision would be cononicalized and the NUW
flag would be added if the loop is finite. The reason is as the comments
says, "since the loop is finite, the bound cannot include the corresponding
boundary (otherwise it would loop forever)." But the NUW flag that be added
also assumes the SCEV that this flag attaches is also NUW in outer loops.
It makes some transformations like IndVars eliminating comparisions
that shouldn' t been eliminated.
Fixes: https://github.com/llvm/llvm-project/issues/60944
I am new to ScalarEvolution. So I am not sure if it is a right fix.
Please reduce the test case.