1 ; RUN: opt -S -enable-loop-simplifycfg-term-folding=true -loop-simplifycfg %s | FileCheck %s
2 ; RUN: opt -S -enable-loop-simplifycfg-term-folding=true -passes='require<domtree>,loop(loop-simplifycfg)' %s | FileCheck %s
4 declare i32* @fake_personality_function()
7 define i32 @test_remove_lpad(i1 %exitcond) personality i32* ()* @fake_personality_function {
8 ; CHECK-LABEL: @test_remove_lpad(
13 br i1 0, label %never, label %next
19 br i1 %exitcond, label %exit, label %for.body
25 invoke void @foo() to label %next unwind label %never-unwind
28 ; CHECK: never-unwind:
29 ; CHECK-NEXT: unreachable
30 %res = landingpad token cleanup
34 define i32 @test_remove_phi_lpad(i1 %exitcond) personality i32* ()* @fake_personality_function {
35 ; CHECK-LABEL: @test_remove_phi_lpad(
40 br i1 0, label %never, label %next
46 br i1 %exitcond, label %exit, label %for.body
52 invoke void @foo() to label %next unwind label %never-unwind
55 ; CHECK: never-unwind:
56 ; CHECK-NEXT: ret i32 undef
57 %p = phi i32 [1, %never]
58 %res = landingpad token cleanup
62 define i32 @test_split_remove_phi_lpad_(i1 %exitcond) personality i32* ()* @fake_personality_function {
63 ; CHECK-LABEL: @test_split_remove_phi_lpad_(
65 invoke void @foo() to label %for.body unwind label %unwind-bb
68 br i1 0, label %never, label %next
74 br i1 %exitcond, label %exit, label %for.body
80 invoke void @foo() to label %next unwind label %unwind-bb
83 ; CHECK: unwind-bb.loopexit:
84 ; CHECK-NEXT: br label %unwind-bb
85 %p = phi i32 [1, %never], [2, %entry]
86 %res = landingpad token cleanup