It can happen that after widening of the IV, flattening may not be possible, e.g. when it is deemed unprofitable. We were not properly checking this, which resulted in flattening being applied when it shouldn't.
This should fix PR51980 (https://bugs.llvm.org/show_bug.cgi?id=51980)
his -> this