; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt -passes=newgvn -S < %s | FileCheck %s
; Check that an unreachable predecessor to a PHI node doesn't cause a crash.
; PR21625.
define i32 @f(ptr %f) {
; CHECK-LABEL: define i32 @f(
; CHECK-SAME: ptr [[F:%.*]]) {
; CHECK-NEXT: bb0:
; CHECK-NEXT: br label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: store i8 poison, ptr null, align 1
; CHECK-NEXT: br i1 false, label [[BB1:%.*]], label [[BB2]]
; CHECK: bb2:
; CHECK-NEXT: [[STOREMERGE:%.*]] = load i32, ptr null, align 4
; CHECK-NEXT: ret i32 [[STOREMERGE]]
;
; Load should be removed, since it's ignored.
bb0:
%bar = load ptr, ptr %f
br label %bb2
bb1:
%zed = load ptr, ptr %f
br i1 false, label %bb1, label %bb2
bb2:
%foo = phi ptr [ null, %bb0 ], [ %zed, %bb1 ]
%storemerge = load i32, ptr %foo
ret i32 %storemerge
}