This fixes https://github.com/llvm/llvm-project/issues/57336. It was exposed by a recent SCEV change, but appears to have been a long standing issue.
Note that the whole insert into the loop instead of a split exit edge is slightly contrived to begin with; it's there solely because IndVarSimplify preserves the CFG.
Any reason we don't just use PN->getIncomingBlock(i)->getTerminator() as the insertion point? That seems like a more obvious place to materialize an edge value.