The way in which GVNPass is currently replacing uses of the instruction being processed with a value already computed is incorrect because it's not considering the possibility that both the replacement and the use are in the same block with the replacement coming after the use. This happens for example when both the blocks we branch to contain identical shl values, as in the LIT test provided. Prior to this patch, this test case results in an invalid dominator tree.
More details in the issue https://github.com/llvm/llvm-project/issues/58418
I'd rename this to load-pre-across-backedge.ll or something, I don't think this has much to do with "identical branches".