1 ; RUN: opt -flattencfg -S < %s | FileCheck %s
4 ; This test checks whether the pass completes without a crash.
5 ; The code is not transformed in any way
7 ; CHECK-LABEL: @test_not_crash
8 define void @test_not_crash(i32 %in_a) #0 {
10 %cmp0 = icmp eq i32 %in_a, -1
11 %cmp1 = icmp ne i32 %in_a, 0
12 %cond0 = and i1 %cmp0, %cmp1
13 br i1 %cond0, label %b0, label %b1
16 %cmp2 = icmp eq i32 %in_a, 0
17 %cmp3 = icmp ne i32 %in_a, 1
18 %cond1 = or i1 %cmp2, %cmp3
19 br i1 %cond1, label %exit, label %b1
21 b1: ; preds = %entry, %b0
24 exit: ; preds = %entry, %b0, %b1
28 ; CHECK-LABEL: @test_not_crash2
30 ; CHECK-NEXT: %0 = fcmp ult float %a
31 ; CHECK-NEXT: %1 = fcmp ult float %b
32 ; CHECK-NEXT: [[COND:%[a-z0-9]+]] = or i1 %0, %1
33 ; CHECK-NEXT: br i1 [[COND]], label %bb4, label %bb3
35 ; CHECK-NEXT: br label %bb4
37 ; CHECK-NEXT: ret void
38 define void @test_not_crash2(float %a, float %b) #0 {
40 %0 = fcmp ult float %a, 1.000000e+00
41 br i1 %0, label %bb0, label %bb1
46 bb4: ; preds = %bb0, %bb3
52 bb0: ; preds = %bb1, %entry
53 %1 = fcmp ult float %b, 1.000000e+00
54 br i1 %1, label %bb4, label %bb3
57 ; CHECK-LABEL: @test_not_crash3
59 ; CHECK-NEXT: %a_eq_0 = icmp eq i32 %a, 0
60 ; CHECK-NEXT: %a_eq_1 = icmp eq i32 %a, 1
61 ; CHECK-NEXT: [[COND:%[a-z0-9]+]] = or i1 %a_eq_0, %a_eq_1
62 ; CHECK-NEXT: br i1 [[COND]], label %bb2, label %bb3
64 ; CHECK-NEXT: br label %bb3
66 ; CHECK-NEXT: %check_badref = phi i32 [ 17, %entry ], [ 11, %bb2 ]
67 ; CHECK-NEXT: ret void
68 define void @test_not_crash3(i32 %a) #0 {
70 %a_eq_0 = icmp eq i32 %a, 0
71 br i1 %a_eq_0, label %bb0, label %bb1
76 bb1: ; preds = %bb0, %entry
77 %a_eq_1 = icmp eq i32 %a, 1
78 br i1 %a_eq_1, label %bb2, label %bb3
83 bb3: ; preds = %bb2, %bb1
84 %check_badref = phi i32 [ 17, %bb1 ], [ 11, %bb2 ]