1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -codegenprepare -S -mtriple=x86_64 < %s | FileCheck %s 3 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 void 12; CHECK: guarded: 13; CHECK-NEXT: ret void 14; 15entry: 16 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 17 %exiplicit_guard_cond = and i1 %cond_0, %widenable_cond 18 br i1 %exiplicit_guard_cond, label %guarded, label %deopt 19 20deopt: ; preds = %entry 21 call void @foo() 22 ret void 23 24guarded: 25 ret void 26} 27 28;; Test a non-guard fastpath/slowpath case 29define 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 void 41; 42entry: 43 %widenable_cond = call i1 @llvm.experimental.widenable.condition() 44 %exiplicit_guard_cond = and i1 %cond_0, %widenable_cond 45 br i1 %exiplicit_guard_cond, label %fastpath, label %slowpath 46 47fastpath: 48 call void @bar() 49 br label %merge 50 51slowpath: 52 call void @foo() 53 br label %merge 54 55merge: 56 ret void 57} 58 59 60; Demonstrate that resulting CFG simplifications are made 61define void @test_cfg_simplify() { 62; CHECK-LABEL: @test_cfg_simplify( 63; CHECK-NEXT: entry: 64; CHECK-NEXT: ret void 65; 66entry: 67 %widenable_cond3 = call i1 @llvm.experimental.widenable.condition() 68 br i1 %widenable_cond3, label %guarded2, label %deopt3 69 70deopt3: 71 call void @foo() 72 ret void 73 74guarded2: 75 %widenable_cond4 = call i1 @llvm.experimental.widenable.condition() 76 br i1 %widenable_cond4, label %merge1, label %slowpath1 77 78slowpath1: 79 call void @foo() 80 br label %merge1 81 82merge1: 83 ret void 84} 85 86 87declare void @foo() 88declare void @bar() 89 90; Function Attrs: inaccessiblememonly nounwind 91declare i1 @llvm.experimental.widenable.condition() #0 92 93attributes #0 = { inaccessiblememonly nounwind } 94