• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
4
5; Interaction between intrinsic and widenable condition guards.
6
7declare void @llvm.experimental.guard(i1,...)
8
9declare void @llvm.experimental.deoptimize.isVoid(...)
10
11; Function Attrs: inaccessiblememonly nounwind
12declare i1 @llvm.experimental.widenable.condition() #0
13
14; Widen condition of intrinsic guard with a condition from widenable branch.
15define void @test_01(i1 %cond_0, i1 %cond_1) {
16; CHECK-LABEL: @test_01(
17; CHECK-NEXT:  entry:
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
23; CHECK:       deopt2:
24; CHECK-NEXT:    call void (...) @llvm.experimental.deoptimize.isVoid() [ "deopt"() ]
25; CHECK-NEXT:    ret void
26; CHECK:       guarded1:
27; CHECK-NEXT:    ret void
28;
29entry:
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
34
35deopt2:                                           ; preds = %guarded
36  call void (...) @llvm.experimental.deoptimize.isVoid() [ "deopt"() ]
37  ret void
38
39guarded1:                                         ; preds = %guarded
40  ret void
41}
42
43; Widen condition of widenable condition guard with a condition from intrinsic.
44define void @test_02(i1 %cond_0, i1 %cond_1) {
45; CHECK-LABEL: @test_02(
46; CHECK-NEXT:  entry:
47; CHECK-NEXT:    [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
48; CHECK-NEXT:    [[WIDE_CHK:%.*]] = and i1 [[COND_0:%.*]], [[COND_1:%.*]]
49; CHECK-NEXT:    [[GUARD_CHK:%.*]] = and i1 [[WIDE_CHK]], [[WIDENABLE_COND]]
50; CHECK-NEXT:    br i1 [[GUARD_CHK]], label [[GUARDED:%.*]], label [[DEOPT:%.*]], !prof !0
51; CHECK:       deopt:
52; CHECK-NEXT:    call void (...) @llvm.experimental.deoptimize.isVoid() [ "deopt"() ]
53; CHECK-NEXT:    ret void
54; CHECK:       guarded:
55; CHECK-NEXT:    ret void
56;
57entry:
58  %widenable_cond = call i1 @llvm.experimental.widenable.condition()
59  %exiplicit_guard_cond = and i1 %cond_0, %widenable_cond
60  br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
61
62deopt:                                            ; preds = %entry
63  call void (...) @llvm.experimental.deoptimize.isVoid() [ "deopt"() ]
64  ret void
65
66guarded:                                          ; preds = %entry
67  call void (i1, ...) @llvm.experimental.guard(i1 %cond_1) [ "deopt"() ]
68  ret void
69}
70
71attributes #0 = { inaccessiblememonly nounwind }
72
73!0 = !{!"branch_weights", i32 1048576, i32 1}
74