[SimplifyCFG] FoldBranchToCommonDest(): properly handle same-block external uses (PR49510/PR49689)
We clone bonus instructions to the end of the predecessor block, and then use `SSAUpdater::RewriteUseAfterInsertions()`. But that only deals with the cases where the use-to-be-rewritten are either in different block from the def, or come after the def. But in some loop cases, the external use may be in the beginning of predecessor block, before the newly cloned bonus instruction. `SSAUpdater::RewriteUseAfterInsertions()` does not deal with that. Notably, the external use can't happen to be both in the same block and *after* the newly-cloned instruction, because of the fold preconditions. To properly handle these cases, when the use is in the same block, we should instead use `SSAUpdater::RewriteUse()`. TBN, they do the same thing for PHI users. Fixes https://bugs.llvm.org/show_bug.cgi?id=49510 Likely Fixes https://bugs.llvm.org/show_bug.cgi?id=49689
Loading
Please register or sign in to comment