1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=gvn -S | FileCheck %s
4 ; This test checks that we don't hang trying to split a critical edge in scalar
5 ; PRE when the control flow uses a callbr instruction.
7 define void @wombat(i64 %arg, ptr %arg1, i64 %arg2, ptr %arg3) {
8 ; CHECK-LABEL: @wombat(
10 ; CHECK-NEXT: [[TMP5:%.*]] = or i64 [[ARG2:%.*]], [[ARG:%.*]]
11 ; CHECK-NEXT: callbr void asm sideeffect "", "!i,!i"()
12 ; CHECK-NEXT: to label [[BB6:%.*]] [label [[BB7:%.*]], label %bb.bb9_crit_edge]
13 ; CHECK: bb.bb9_crit_edge:
14 ; CHECK-NEXT: [[DOTPRE:%.*]] = trunc i64 [[TMP5]] to i32
15 ; CHECK-NEXT: br label [[BB9:%.*]]
17 ; CHECK-NEXT: br label [[BB7]]
19 ; CHECK-NEXT: [[TMP8:%.*]] = trunc i64 [[TMP5]] to i32
20 ; CHECK-NEXT: tail call void @barney(i32 [[TMP8]])
21 ; CHECK-NEXT: br label [[BB9]]
23 ; CHECK-NEXT: [[TMP10_PRE_PHI:%.*]] = phi i32 [ [[DOTPRE]], [[BB_BB9_CRIT_EDGE:%.*]] ], [ [[TMP8]], [[BB7]] ]
24 ; CHECK-NEXT: store i32 [[TMP10_PRE_PHI]], ptr [[ARG3:%.*]], align 4
25 ; CHECK-NEXT: ret void
28 %tmp5 = or i64 %arg2, %arg
29 callbr void asm sideeffect "", "!i,!i"()
30 to label %bb6 [label %bb7, label %bb9]
35 bb7: ; preds = %bb6, %bb
36 %tmp8 = trunc i64 %tmp5 to i32
37 tail call void @barney(i32 %tmp8)
40 bb9: ; preds = %bb7, %bb
41 %tmp10 = trunc i64 %tmp5 to i32
42 store i32 %tmp10, ptr %arg3
46 declare void @barney(i32)