89 lines · plain
1; RUN: opt -S -enable-loop-simplifycfg-term-folding=true -passes=loop-simplifycfg %s | FileCheck %s2; RUN: opt -S -enable-loop-simplifycfg-term-folding=true -passes='require<domtree>,loop(loop-simplifycfg)' %s | FileCheck %s3 4declare ptr @fake_personality_function()5declare void @foo()6 7define i32 @test_remove_lpad(i1 %exitcond) personality ptr @fake_personality_function {8; CHECK-LABEL: @test_remove_lpad(9entry:10 br label %for.body11 12for.body:13 br i1 0, label %never, label %next14 15next:16 br label %latch17 18latch:19 br i1 %exitcond, label %exit, label %for.body20 21exit:22 ret i32 023 24never:25 invoke void @foo() to label %next unwind label %never-unwind26 27never-unwind:28; CHECK: never-unwind:29; CHECK-NEXT: unreachable30 %res = landingpad token cleanup31 unreachable32}33 34define i32 @test_remove_phi_lpad(i1 %exitcond) personality ptr @fake_personality_function {35; CHECK-LABEL: @test_remove_phi_lpad(36entry:37 br label %for.body38 39for.body:40 br i1 0, label %never, label %next41 42next:43 br label %latch44 45latch:46 br i1 %exitcond, label %exit, label %for.body47 48exit:49 ret i32 050 51never:52 invoke void @foo() to label %next unwind label %never-unwind53 54never-unwind:55; CHECK: never-unwind:56; CHECK-NEXT: ret i32 poison57 %p = phi i32 [1, %never]58 %res = landingpad token cleanup59 ret i32 %p60}61 62define i32 @test_split_remove_phi_lpad_(i1 %exitcond) personality ptr @fake_personality_function {63; CHECK-LABEL: @test_split_remove_phi_lpad_(64entry:65 invoke void @foo() to label %for.body unwind label %unwind-bb66 67for.body:68 br i1 0, label %never, label %next69 70next:71 br label %latch72 73latch:74 br i1 %exitcond, label %exit, label %for.body75 76exit:77 ret i32 078 79never:80 invoke void @foo() to label %next unwind label %unwind-bb81 82unwind-bb:83; CHECK: unwind-bb.loopexit:84; CHECK-NEXT: br label %unwind-bb85 %p = phi i32 [1, %never], [2, %entry]86 %res = landingpad token cleanup87 ret i32 %p88}89