• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -S -gvn-hoist -newgvn < %s | FileCheck %s
2
3; Check that store hoisting works: there should be only one store left.
4; CHECK-LABEL: @getopt
5; CHECK: store i32
6; CHECK-NOT: store i32
7
8@optind = external global i32, align 4
9
10define void @getopt() {
11bb:
12  br label %bb1
13
14bb1:                                              ; preds = %bb
15  br i1 undef, label %bb2, label %bb3
16
17bb2:                                              ; preds = %bb1
18  br label %bb13
19
20bb3:                                              ; preds = %bb1
21  br i1 undef, label %bb4, label %bb9
22
23bb4:                                              ; preds = %bb3
24  %tmp = load i32, i32* @optind, align 4
25  br i1 undef, label %bb5, label %bb7
26
27bb5:                                              ; preds = %bb4
28  %tmp6 = add nsw i32 %tmp, 1
29  store i32 %tmp6, i32* @optind, align 4
30  br label %bb12
31
32bb7:                                              ; preds = %bb4
33  %tmp8 = add nsw i32 %tmp, 1
34  store i32 %tmp8, i32* @optind, align 4
35  br label %bb13
36
37bb9:                                              ; preds = %bb3
38  %tmp10 = load i32, i32* @optind, align 4
39  %tmp11 = add nsw i32 %tmp10, 1
40  store i32 %tmp11, i32* @optind, align 4
41  br label %bb12
42
43bb12:                                             ; preds = %bb9, %bb5
44  br label %bb13
45
46bb13:                                             ; preds = %bb12, %bb7, %bb2
47  ret void
48}
49
50@GlobalVar = internal global float 1.000000e+00
51
52; Check that we hoist stores and remove the MSSA phi node.
53; CHECK-LABEL: @hoistStoresUpdateMSSA
54; CHECK: store float
55; CHECK-NOT: store float
56define float @hoistStoresUpdateMSSA(float %d) {
57entry:
58  store float 0.000000e+00, float* @GlobalVar
59  %cmp = fcmp oge float %d, 0.000000e+00
60  br i1 %cmp, label %if.then, label %if.end
61
62if.then:
63  store float 0.000000e+00, float* @GlobalVar
64  br label %if.end
65
66if.end:
67  %tmp = load float, float* @GlobalVar, align 4
68  ret float %tmp
69}
70