LowerSwitch: replace unreachable default with popular case destination
[oota-llvm.git] / test / Transforms / LowerSwitch / 2014-06-23-PHIlowering.ll
1 ; RUN: opt < %s -lowerswitch -S | FileCheck %s
2
3 define i32 @test(i32 %arg) #0 {
4 ; CHECK-LABEL: @test
5 ; CHECK: ; <label>:2
6 ; CHECK-NEXT:  %res.0 = phi i32 [ 1, %NodeBlock ], [ 2, %1 ]
7 ; CHECK-NEXT:  br label %3
8 ; CHECK: ; <label>:5
9 ; CHECK-NEXT:   %res.3 = phi i32 [ 0, %NewDefault ], [ %res.2, %4 ]
10 ; CHECK-NEXT:   %6 = add nsw i32 %res.3, 1
11 ; CHECK-NEXT:   ret i32 %6
12
13   switch i32 %arg, label %5 [
14     i32 1, label %1
15     i32 2, label %2
16     i32 3, label %3
17     i32 4, label %4
18   ]
19
20 ; <label>:1
21   br label %2
22
23 ; <label>:2
24   %res.0 = phi i32 [ 1, %0 ], [ 2, %1 ]
25   br label %3
26
27 ; <label>:3
28   %res.1 = phi i32 [ 0, %0 ], [ %res.0, %2 ]
29   %phitmp = add nsw i32 %res.1, 2
30   br label %4
31
32 ; <label>:4
33   %res.2 = phi i32 [ 1, %0 ], [ %phitmp, %3 ]
34   br label %5
35
36 ; <label>:5
37   %res.3 = phi i32 [ 0, %0 ], [ %res.2, %4 ]
38   %6 = add nsw i32 %res.3, 1
39   ret i32 %6
40 }