Michael Zolotukhin | 5020c99 | 2016-11-18 21:01:12 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -lcssa -licm -S | FileCheck %s |
| 2 | ; PR30454 |
| 3 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 4 | target triple = "x86_64-unknown-linux-gnu" |
| 5 | |
| 6 | declare i8 @bar() |
| 7 | |
| 8 | ; Test that we preserve LCSSA form when removing edges from unreachable blocks. |
| 9 | ; CHECK-LABEL: @foo |
| 10 | define void @foo() { |
| 11 | entry: |
| 12 | br label %for.cond |
| 13 | |
| 14 | for.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 |
| 20 | unreachable.bb: |
| 21 | br i1 undef, label %exit, label %for.latch |
| 22 | |
| 23 | for.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 ] |
| 29 | exit: |
| 30 | %z = zext i8 %x to i32 |
| 31 | ret void |
| 32 | } |