If the icmp is in a different block, then the register for the icmp operand may not be initialized, as it nominally does not have cross-block uses. Add a check that the icmp is in the same block as the branch, which should be the common case.
This matches what X86 FastISel does: https://github.com/llvm/llvm-project/blob/5b6b090cf2129228f05d7d0f504676b67f7524cf/llvm/lib/Target/X86/X86FastISel.cpp#L1648
This code could principally have the same issue. However, it's also dead code, so I just dropped it entirely.
The reason it's dead is that V must have i1 type here (used either as a branch or select condition), while this checks that the type is i32.