1; RUN: opt < %s -lcssa -licm -S | FileCheck %s
2; PR30454
3target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4target triple = "x86_64-unknown-linux-gnu"
5
6declare i8 @bar()
7
8; Test that we preserve LCSSA form when removing edges from unreachable blocks.
9; CHECK-LABEL: @foo
10define void @foo() {
11entry:
12  br label %for.cond
13
14for.cond:
15  %x = phi i8 [ undef, %entry ], [ %y, %for.latch ]
16  br i1 undef, label %for.latch, label %exit
17
18; CHECK:      unreachable.bb:
19; CHECK-NEXT:   unreachable
20unreachable.bb:
21  br i1 undef, label %exit, label %for.latch
22
23for.latch:
24  %y = call i8 @bar()
25  br label %for.cond
26
27; CHECK:      exit:
28; CHECK-NEXT:   %x.lcssa = phi i8 [ %x, %for.cond ]
29exit:
30  %z = zext i8 %x to i32
31  ret void
32}
33