1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -guard-widening-widen-branch-guards=true -guard-widening < %s | FileCheck %s
3 ; RUN: opt -S -guard-widening-widen-branch-guards=true -passes=guard-widening < %s | FileCheck %s
5 ; Interaction between intrinsic and widenable condition guards.
7 declare void @llvm.experimental.guard(i1,...)
9 declare void @llvm.experimental.deoptimize.isVoid(...)
11 ; Function Attrs: inaccessiblememonly nounwind
12 declare i1 @llvm.experimental.widenable.condition() #0
14 ; Widen condition of intrinsic guard with a condition from widenable branch.
15 define void @test_01(i1 %cond_0, i1 %cond_1) {
16 ; CHECK-LABEL: @test_01(
18 ; CHECK-NEXT: [[WIDE_CHK:%.*]] = and i1 [[COND_0:%.*]], [[COND_1:%.*]]
19 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WIDE_CHK]]) [ "deopt"() ]
20 ; CHECK-NEXT: [[WIDENABLE_COND3:%.*]] = call i1 @llvm.experimental.widenable.condition()
21 ; CHECK-NEXT: [[EXIPLICIT_GUARD_COND4:%.*]] = and i1 [[COND_1]], [[WIDENABLE_COND3]]
22 ; CHECK-NEXT: br i1 true, label [[GUARDED1:%.*]], label [[DEOPT2:%.*]], !prof !0
24 ; CHECK-NEXT: call void (...) @llvm.experimental.deoptimize.isVoid() [ "deopt"() ]
25 ; CHECK-NEXT: ret void
27 ; CHECK-NEXT: ret void
30 call void (i1, ...) @llvm.experimental.guard(i1 %cond_0) [ "deopt"() ]
31 %widenable_cond3 = call i1 @llvm.experimental.widenable.condition()
32 %exiplicit_guard_cond4 = and i1 %cond_1, %widenable_cond3
33 br i1 %exiplicit_guard_cond4, label %guarded1, label %deopt2, !prof !0
35 deopt2: ; preds = %guarded
36 call void (...) @llvm.experimental.deoptimize.isVoid() [ "deopt"() ]
39 guarded1: ; preds = %guarded
43 ; Widen condition of widenable condition guard with a condition from intrinsic.
44 define void @test_02(i1 %cond_0, i1 %cond_1) {
45 ; CHECK-LABEL: @test_02(
47 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
48 ; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[COND_0:%.*]], [[WIDENABLE_COND]]
49 ; CHECK-NEXT: [[WIDE_CHK:%.*]] = and i1 [[COND_0]], [[COND_1:%.*]]
50 ; CHECK-NEXT: [[GUARD_CHK:%.*]] = and i1 [[WIDE_CHK]], [[WIDENABLE_COND]]
51 ; CHECK-NEXT: br i1 [[GUARD_CHK]], label [[GUARDED:%.*]], label [[DEOPT:%.*]], !prof !0
53 ; CHECK-NEXT: call void (...) @llvm.experimental.deoptimize.isVoid() [ "deopt"() ]
54 ; CHECK-NEXT: ret void
56 ; CHECK-NEXT: ret void
59 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
60 %exiplicit_guard_cond = and i1 %cond_0, %widenable_cond
61 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
63 deopt: ; preds = %entry
64 call void (...) @llvm.experimental.deoptimize.isVoid() [ "deopt"() ]
67 guarded: ; preds = %entry
68 call void (i1, ...) @llvm.experimental.guard(i1 %cond_1) [ "deopt"() ]
72 attributes #0 = { inaccessiblememonly nounwind }
74 !0 = !{!"branch_weights", i32 1048576, i32 1}