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
; RUN: llc -mtriple=i686-linux < %s | FileCheck %s

; Don't rotate the loop if the number of fall through to exit is not larger
; than the number of fall through to header.
define void @no_rotate() {
; CHECK-LABEL: no_rotate
; CHECK: %entry
; CHECK: %header
; CHECK: %middle
; CHECK: %latch1
; CHECK: %latch2
; CHECK: %end
entry:
  br label %header

header:
  %val1 = call i1 @foo()
  br i1 %val1, label %middle, label %end

middle:
  %val2 = call i1 @foo()
  br i1 %val2, label %latch1, label %end

latch1:
  %val3 = call i1 @foo()
  br i1 %val3, label %latch2, label %header

latch2:
  %val4 = call i1 @foo()
  br label %header

end:
  ret void
}

define void @do_rotate() {
; CHECK-LABEL: do_rotate
; CHECK: %entry
; CHECK: %then
; CHECK: %else
; CHECK: %latch1
; CHECK: %latch2
; CHECK: %header
; CHECK: %end
entry:
  %val0 = call i1 @foo()
  br i1 %val0, label %then, label %else

then:
  call void @a()
  br label %header

else:
  call void @b()
  br label %header

header:
  %val1 = call i1 @foo()
  br i1 %val1, label %latch1, label %end

latch1:
  %val3 = call i1 @foo()
  br i1 %val3, label %latch2, label %header

latch2:
  %val4 = call i1 @foo()
  br label %header

end:
  ret void
}

; The loop structure is same as in @no_rotate, but the loop header's predecessor
; doesn't fall through to it, so it should be rotated to get exit fall through.
define void @do_rotate2() {
; CHECK-LABEL: do_rotate2
; CHECK: %entry
; CHECK: %then
; CHECK: %middle
; CHECK: %latch1
; CHECK: %latch2
; CHECK: %header
; CHECK: %exit
entry:
  %val0 = call i1 @foo()
  br i1 %val0, label %then, label %header, !prof !1

then:
  call void @a()
  br label %end

header:
  %val1 = call i1 @foo()
  br i1 %val1, label %middle, label %exit

middle:
  %val2 = call i1 @foo()
  br i1 %val2, label %latch1, label %exit

latch1:
  %val3 = call i1 @foo()
  br i1 %val3, label %latch2, label %header

latch2:
  %val4 = call i1 @foo()
  br label %header

exit:
  call void @b()
  br label %end

end:
  ret void
}

declare i1 @foo()
declare void @a()
declare void @b()

!1 = !{!"branch_weights", i32 10, i32 1}