1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -codegenprepare -S < %s | FileCheck %s
4 ; Check the idiomatic guard pattern to ensure it's lowered correctly.
5 define void @test_guard(i1 %cond_0) {
6 ; CHECK-LABEL: @test_guard(
8 ; CHECK-NEXT: br i1 [[COND_0:%.*]], label [[GUARDED:%.*]], label [[DEOPT:%.*]]
10 ; CHECK-NEXT: call void @foo()
11 ; CHECK-NEXT: ret void
13 ; CHECK-NEXT: ret void
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
20 deopt: ; preds = %entry
28 ;; Test a non-guard fastpath/slowpath case
29 define void @test_triangle(i1 %cond_0) {
30 ; CHECK-LABEL: @test_triangle(
32 ; CHECK-NEXT: br i1 [[COND_0:%.*]], label [[FASTPATH:%.*]], label [[SLOWPATH:%.*]]
34 ; CHECK-NEXT: call void @bar()
35 ; CHECK-NEXT: br label [[MERGE:%.*]]
37 ; CHECK-NEXT: call void @foo()
38 ; CHECK-NEXT: br label [[MERGE]]
40 ; CHECK-NEXT: ret void
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
60 ; Demonstrate that resulting CFG simplifications are made
61 define void @test_cfg_simplify() {
62 ; CHECK-LABEL: @test_cfg_simplify(
64 ; CHECK-NEXT: ret void
67 %widenable_cond3 = call i1 @llvm.experimental.widenable.condition()
68 br i1 %widenable_cond3, label %guarded2, label %deopt3
75 %widenable_cond4 = call i1 @llvm.experimental.widenable.condition()
76 br i1 %widenable_cond4, label %merge1, label %slowpath1
90 ; Function Attrs: inaccessiblememonly nounwind
91 declare i1 @llvm.experimental.widenable.condition() #0
93 attributes #0 = { inaccessiblememonly nounwind }