[llvm] [SimplifyCFG] Add loop metadata to the new branch when doing jump-threading (PR #157180)

Hongyu Chen via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 2 21:43:03 PDT 2025


XChy wrote:

> In your specific example, it seems like we actually end with the loop metadata attached to a terminator that is a latch for two _different_ loops, so that can probably end up applying the metadata to the wrong loop? (Previously it was applied to the outer loop, but now it also applies to the inner?)

Sorry for misreading the LangRef. I was not aware of applying the metadata to both loops. I agree it's incorrect too.

> If we're threading the latch, doesn't it depend on the threaded successor whether the result is another latch or not?

Looks like we cannot fix metadata without loop info here. And there may be other problems, such as whether the metadata on these latches is not persistent for the same loop.

https://github.com/llvm/llvm-project/pull/157180


More information about the llvm-commits mailing list