1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -guard-widening-widen-branch-guards=true -passes=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: [[COND_1_GW_FR:%.*]] = freeze i1 [[COND_1:%.*]]
19 ; CHECK-NEXT: [[WIDE_CHK:%.*]] = and i1 [[COND_0:%.*]], [[COND_1_GW_FR]]
20 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WIDE_CHK]]) [ "deopt"() ]
21 ; CHECK-NEXT: [[WIDENABLE_COND3:%.*]] = call i1 @llvm.experimental.widenable.condition()
22 ; CHECK-NEXT: [[EXIPLICIT_GUARD_COND4:%.*]] = and i1 [[COND_1_GW_FR]], [[WIDENABLE_COND3]]
23 ; CHECK-NEXT: br i1 true, label [[GUARDED1:%.*]], label [[DEOPT2:%.*]], !prof [[PROF0:![0-9]+]]
25 ; CHECK-NEXT: call void (...) @llvm.experimental.deoptimize.isVoid() [ "deopt"() ]
26 ; CHECK-NEXT: ret void
28 ; CHECK-NEXT: ret void
31 call void (i1, ...) @llvm.experimental.guard(i1 %cond_0) [ "deopt"() ]
32 %widenable_cond3 = call i1 @llvm.experimental.widenable.condition()
33 %exiplicit_guard_cond4 = and i1 %cond_1, %widenable_cond3
34 br i1 %exiplicit_guard_cond4, label %guarded1, label %deopt2, !prof !0
36 deopt2: ; preds = %guarded
37 call void (...) @llvm.experimental.deoptimize.isVoid() [ "deopt"() ]
40 guarded1: ; preds = %guarded
44 ; Widen condition of widenable condition guard with a condition from intrinsic.
45 define void @test_02(i1 %cond_0, i1 %cond_1) {
46 ; CHECK-LABEL: @test_02(
48 ; CHECK-NEXT: [[COND_1_GW_FR:%.*]] = freeze i1 [[COND_1:%.*]]
49 ; CHECK-NEXT: [[WIDE_CHK:%.*]] = and i1 [[COND_0:%.*]], [[COND_1_GW_FR]]
50 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
51 ; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[WIDE_CHK]], [[WIDENABLE_COND]]
52 ; CHECK-NEXT: br i1 [[EXIPLICIT_GUARD_COND]], label [[GUARDED:%.*]], label [[DEOPT:%.*]], !prof [[PROF0]]
54 ; CHECK-NEXT: call void (...) @llvm.experimental.deoptimize.isVoid() [ "deopt"() ]
55 ; CHECK-NEXT: ret void
57 ; CHECK-NEXT: ret void
60 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
61 %exiplicit_guard_cond = and i1 %cond_0, %widenable_cond
62 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
64 deopt: ; preds = %entry
65 call void (...) @llvm.experimental.deoptimize.isVoid() [ "deopt"() ]
68 guarded: ; preds = %entry
69 call void (i1, ...) @llvm.experimental.guard(i1 %cond_1) [ "deopt"() ]
73 attributes #0 = { inaccessiblememonly nounwind }
75 !0 = !{!"branch_weights", i32 1048576, i32 1}