1 ; RUN: opt -S -passes='function(gvn-hoist),function(newgvn)' < %s | FileCheck %s
3 ; Check that store hoisting works: there should be only one store left.
8 @optind = external global i32, align 4
10 define void @getopt(i1 %arg) {
15 br i1 %arg, label %bb2, label %bb3
21 br i1 %arg, label %bb4, label %bb9
24 %tmp = load i32, ptr @optind, align 4
25 br i1 %arg, label %bb5, label %bb7
28 %tmp6 = add nsw i32 %tmp, 1
29 store i32 %tmp6, ptr @optind, align 4
33 %tmp8 = add nsw i32 %tmp, 1
34 store i32 %tmp8, ptr @optind, align 4
38 %tmp10 = load i32, ptr @optind, align 4
39 %tmp11 = add nsw i32 %tmp10, 1
40 store i32 %tmp11, ptr @optind, align 4
43 bb12: ; preds = %bb9, %bb5
46 bb13: ; preds = %bb12, %bb7, %bb2
50 @GlobalVar = internal global float 1.000000e+00
52 ; Check that we hoist stores and remove the MSSA phi node.
53 ; CHECK-LABEL: @hoistStoresUpdateMSSA
55 ; CHECK-NOT: store float
56 define float @hoistStoresUpdateMSSA(float %d) {
58 store float 0.000000e+00, ptr @GlobalVar
59 %cmp = fcmp oge float %d, 0.000000e+00
60 br i1 %cmp, label %if.then, label %if.end
63 store float 0.000000e+00, ptr @GlobalVar
67 %tmp = load float, ptr @GlobalVar, align 4