reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
; RUN: opt -verify-loop-info -irce -irce-print-range-checks -irce-print-changed-loops %s -S 2>&1 | FileCheck %s
; RUN: opt -verify-loop-info -passes='require<branch-prob>,loop(irce)' -irce-print-range-checks -irce-print-changed-loops %s -S 2>&1 | FileCheck %s

; Make sure that we can pick up both range checks.
define void @test_01(i32 *%arr, i32* %a_len_ptr, i32* %size_ptr) {

; CHECK-LABEL: @test_01(

entry:
  %len = load i32, i32* %a_len_ptr, !range !0
  %size = load i32, i32* %size_ptr
  %first_iter_check = icmp sle i32 %size, 0
  br i1 %first_iter_check, label %exit, label %loop

loop:
  %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]
  %rc1 = icmp slt i32 %iv, %len
  %rc2 = icmp slt i32 %iv, %size
  ; CHECK: %rc = and i1 true, true
  %rc = and i1 %rc1, %rc2
  br i1 %rc, label %backedge, label %out_of_bounds


backedge:
  %iv.next = add i32 %iv, 1
  %arr_el_ptr = getelementptr i32, i32* %arr, i32 %iv
  %el = load i32, i32* %arr_el_ptr
  %loopcond = icmp ne i32 %iv, %size
  br i1 %loopcond, label %loop, label %exit

exit:
  ret void

out_of_bounds:
  ret void
}

; Same as test_01, unsigned predicates.
define void @test_02(i32 *%arr, i32* %a_len_ptr, i32* %size_ptr) {

; CHECK-LABEL: @test_02(

entry:
  %len = load i32, i32* %a_len_ptr, !range !0
  %size = load i32, i32* %size_ptr
  %first_iter_check = icmp sle i32 %size, 0
  br i1 %first_iter_check, label %exit, label %loop

loop:
  %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]
  %rc1 = icmp ult i32 %iv, %len
  %rc2 = icmp ult i32 %iv, %size
  ; CHECK: %rc = and i1 true, true
  %rc = and i1 %rc1, %rc2
  br i1 %rc, label %backedge, label %out_of_bounds


backedge:
  %iv.next = add i32 %iv, 1
  %arr_el_ptr = getelementptr i32, i32* %arr, i32 %iv
  %el = load i32, i32* %arr_el_ptr
  %loopcond = icmp ne i32 %iv, %size
  br i1 %loopcond, label %loop, label %exit

exit:
  ret void

out_of_bounds:
  ret void
}

define void @test_03(i32 *%arr, i32* %a_len_ptr, i32* %size_ptr) {

; CHECK-LABEL: @test_03(

entry:
  %len = load i32, i32* %a_len_ptr, !range !0
  %size = load i32, i32* %size_ptr
  %first_iter_check = icmp eq i32 %size, 0
  br i1 %first_iter_check, label %exit, label %loop

loop:
  %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]
  %rc1 = icmp slt i32 %iv, %len
  %rc2 = icmp slt i32 %iv, %size
  ; CHECK: %rc = and i1 true, true
  %rc = and i1 %rc1, %rc2
  br i1 %rc, label %backedge, label %out_of_bounds


backedge:
  %iv.next = add i32 %iv, 1
  %arr_el_ptr = getelementptr i32, i32* %arr, i32 %iv
  %el = load i32, i32* %arr_el_ptr
  %loopcond = icmp ne i32 %iv, %len
  br i1 %loopcond, label %loop, label %exit

exit:
  ret void

out_of_bounds:
  ret void
}

define void @test_04(i32 *%arr, i32* %a_len_ptr, i32* %size_ptr) {

; CHECK-LABEL: @test_04(

entry:
  %len = load i32, i32* %a_len_ptr, !range !0
  %size = load i32, i32* %size_ptr
  %first_iter_check = icmp eq i32 %size, 0
  br i1 %first_iter_check, label %exit, label %loop

loop:
  %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]
  %rc1 = icmp ult i32 %iv, %len
  %rc2 = icmp ult i32 %iv, %size
  ; CHECK: %rc = and i1 true, true
  %rc = and i1 %rc1, %rc2
  br i1 %rc, label %backedge, label %out_of_bounds


backedge:
  %iv.next = add i32 %iv, 1
  %arr_el_ptr = getelementptr i32, i32* %arr, i32 %iv
  %el = load i32, i32* %arr_el_ptr
  %loopcond = icmp ne i32 %iv, %len
  br i1 %loopcond, label %loop, label %exit

exit:
  ret void

out_of_bounds:
  ret void
}

!0 = !{i32 0, i32 2147483647}
!1 = !{!"branch_weights", i32 64, i32 4}