1; RUN: opt -S -gvn-hoist < %s | FileCheck %s
2
3%struct.__jmp_buf_tag = type { [8 x i64], i32 }
4
5; Check that hoisting only happens when the expression is very busy.
6; CHECK: store
7; CHECK: store
8
9@test_exit_buf = global %struct.__jmp_buf_tag zeroinitializer
10@G = global i32 0
11
12define void @test_command(i32 %c1) {
13entry:
14  switch i32 %c1, label %exit [
15    i32 0, label %sw0
16    i32 1, label %sw1
17  ]
18
19sw0:
20  store i32 1, i32* @G
21  br label %exit
22
23sw1:
24  store i32 1, i32* @G
25  br label %exit
26
27exit:
28  call void @longjmp(%struct.__jmp_buf_tag* @test_exit_buf, i32 1) #0
29  unreachable
30}
31
32declare void @longjmp(%struct.__jmp_buf_tag*, i32) #0
33
34attributes #0 = { noreturn nounwind }
35
36; Check that the store is hoisted.
37; CHECK-LABEL: define void @fun(
38; CHECK: store
39; CHECK-NOT: store
40
41define void @fun() {
42entry:
43  br label %if.then
44
45if.then:                                          ; preds = %entry
46  br i1 undef, label %sw0, label %sw1
47
48sw0:
49  store i32 1, i32* @G
50  unreachable
51
52sw1:
53  store i32 1, i32* @G
54  ret void
55}
56