While writing a blog post I tried to explain why it is always safe to transfer IR nowrap flags to the pre-inc addrec, and ... couldn't, because I don't think it's correct. The most straightforward example would be two {0,+,1} addrecs, one of them has a nuw flag in IR but is never used, and the other doesn't have one and is used. We could incorrectly transfer the nuw flag from the former to the latter.
I believe we can transfer the nowrap flags only if either a) the addrec is known non-poison or b) the post-inc instruction being poison would cause UB in a latch-dominating instruction. In particular, this includes the IV being used in any exit condition.
This patch is still WIP because I need to properly update tests, but I wanted to put this up for some early feedback.
Precommit check regeneration?