Restore fixed version of "[CodeGenPrepare] Fix isIVIncrement (PR49466)"
Change was reverted in commit 8d20f2c2 because it was causing an infinite loop. 9228f2f3 fixed the root issue in the code structure, this change just reapplies the original change w/adaptation to the new code structure.