94 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -passes='require<profile-summary>,function(codegenprepare)' -S -mtriple=x86_64 < %s | FileCheck %s3 4; Check the idiomatic guard pattern to ensure it's lowered correctly.5define void @test_guard(i1 %cond_0) {6; CHECK-LABEL: @test_guard(7; CHECK-NEXT: entry:8; CHECK-NEXT: br i1 [[COND_0:%.*]], label [[GUARDED:%.*]], label [[DEOPT:%.*]]9; CHECK: deopt:10; CHECK-NEXT: call void @foo()11; CHECK-NEXT: ret void12; CHECK: guarded:13; CHECK-NEXT: ret void14;15entry:16 %widenable_cond = call i1 @llvm.experimental.widenable.condition()17 %exiplicit_guard_cond = and i1 %cond_0, %widenable_cond18 br i1 %exiplicit_guard_cond, label %guarded, label %deopt19 20deopt: ; preds = %entry21 call void @foo()22 ret void23 24guarded:25 ret void26}27 28;; Test a non-guard fastpath/slowpath case29define void @test_triangle(i1 %cond_0) {30; CHECK-LABEL: @test_triangle(31; CHECK-NEXT: entry:32; CHECK-NEXT: br i1 [[COND_0:%.*]], label [[FASTPATH:%.*]], label [[SLOWPATH:%.*]]33; CHECK: fastpath:34; CHECK-NEXT: call void @bar()35; CHECK-NEXT: br label [[MERGE:%.*]]36; CHECK: slowpath:37; CHECK-NEXT: call void @foo()38; CHECK-NEXT: br label [[MERGE]]39; CHECK: merge:40; CHECK-NEXT: ret void41;42entry:43 %widenable_cond = call i1 @llvm.experimental.widenable.condition()44 %exiplicit_guard_cond = and i1 %cond_0, %widenable_cond45 br i1 %exiplicit_guard_cond, label %fastpath, label %slowpath46 47fastpath:48 call void @bar()49 br label %merge50 51slowpath:52 call void @foo()53 br label %merge54 55merge:56 ret void57}58 59 60; Demonstrate that resulting CFG simplifications are made61define void @test_cfg_simplify() {62; CHECK-LABEL: @test_cfg_simplify(63; CHECK-NEXT: entry:64; CHECK-NEXT: ret void65;66entry:67 %widenable_cond3 = call i1 @llvm.experimental.widenable.condition()68 br i1 %widenable_cond3, label %guarded2, label %deopt369 70deopt3:71 call void @foo()72 ret void73 74guarded2:75 %widenable_cond4 = call i1 @llvm.experimental.widenable.condition()76 br i1 %widenable_cond4, label %merge1, label %slowpath177 78slowpath1:79 call void @foo()80 br label %merge181 82merge1:83 ret void84}85 86 87declare void @foo()88declare void @bar()89 90; Function Attrs: inaccessiblememonly nounwind91declare i1 @llvm.experimental.widenable.condition() #092 93attributes #0 = { inaccessiblememonly nounwind }94