1 ; RUN: opt -S -gvn-hoist -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() {
15 br i1 undef, label %bb2, label %bb3
21 br i1 undef, label %bb4, label %bb9
24 %tmp = load i32, i32* @optind, align 4
25 br i1 undef, label %bb5, label %bb7
28 %tmp6 = add nsw i32 %tmp, 1
29 store i32 %tmp6, i32* @optind, align 4
33 %tmp8 = add nsw i32 %tmp, 1
34 store i32 %tmp8, i32* @optind, align 4
38 %tmp10 = load i32, i32* @optind, align 4
39 %tmp11 = add nsw i32 %tmp10, 1
40 store i32 %tmp11, i32* @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, float* @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, float* @GlobalVar
67 %tmp = load float, float* @GlobalVar, align 4