1; RUN: opt -lowerswitch -S < %s | FileCheck %s 2 3; Test that we don't crash and have a different basic block for each incoming edge. 4define void @test0() { 5; CHECK-LABEL: @test0 6; CHECK: %merge = phi i64 [ 1, %BB3 ], [ 0, %NewDefault ], [ 0, %NodeBlock5 ], [ 0, %LeafBlock1 ] 7BB1: 8 switch i32 undef, label %BB2 [ 9 i32 3, label %BB2 10 i32 5, label %BB2 11 i32 0, label %BB3 12 i32 2, label %BB3 13 i32 4, label %BB3 14 ] 15 16BB2: 17 %merge = phi i64 [ 1, %BB3 ], [ 0, %BB1 ], [ 0, %BB1 ], [ 0, %BB1 ] 18 ret void 19 20BB3: 21 br label %BB2 22} 23 24; Test switch cases that are merged into a single case during lowerswitch 25; (take 84 and 85 below) - check that the number of incoming phi values match 26; the number of branches. 27define void @test1() { 28; CHECK-LABEL: @test1 29entry: 30 br label %bb1 31 32bb1: 33 switch i32 undef, label %bb1 [ 34 i32 84, label %bb3 35 i32 85, label %bb3 36 i32 86, label %bb2 37 i32 78, label %exit 38 i32 99, label %bb3 39 ] 40 41bb2: 42 br label %bb3 43 44bb3: 45; CHECK-LABEL: bb3 46; CHECK: %tmp = phi i32 [ 1, %NodeBlock ], [ 0, %bb2 ], [ 1, %LeafBlock3 ] 47 %tmp = phi i32 [ 1, %bb1 ], [ 0, %bb2 ], [ 1, %bb1 ], [ 1, %bb1 ] 48; CHECK-NEXT: %tmp2 = phi i32 [ 2, %NodeBlock ], [ 5, %bb2 ], [ 2, %LeafBlock3 ] 49 %tmp2 = phi i32 [ 2, %bb1 ], [ 2, %bb1 ], [ 5, %bb2 ], [ 2, %bb1 ] 50 br label %exit 51 52exit: 53 ret void 54} 55