56 lines · plain
1; RUN: opt -S -passes=gvn-hoist < %s | FileCheck %s2 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: store7; CHECK: store8 9@test_exit_buf = global %struct.__jmp_buf_tag zeroinitializer10@G = global i32 011 12define void @test_command(i32 %c1) {13entry:14 switch i32 %c1, label %exit [15 i32 0, label %sw016 i32 1, label %sw117 ]18 19sw0:20 store i32 1, ptr @G21 br label %exit22 23sw1:24 store i32 1, ptr @G25 br label %exit26 27exit:28 call void @longjmp(ptr @test_exit_buf, i32 1) #029 unreachable30}31 32declare void @longjmp(ptr, i32) #033 34attributes #0 = { noreturn nounwind }35 36; Check that the store is hoisted.37; CHECK-LABEL: define void @fun(38; CHECK: store39; CHECK-NOT: store40 41define void @fun(i1 %arg) {42entry:43 br label %if.then44 45if.then: ; preds = %entry46 br i1 %arg, label %sw0, label %sw147 48sw0:49 store i32 1, ptr @G50 unreachable51 52sw1:53 store i32 1, ptr @G54 ret void55}56