1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
2 ; RUN: opt < %s -S -passes=loop-unroll -unroll-force-peel-count=2 2>&1 | FileCheck %s
3 ; RUN: opt < %s -S -passes=loop-unroll -unroll-force-peel-count=2 -disable-advanced-peeling 2>&1 | FileCheck %s --check-prefix=DISABLEADV
7 ; Test branch weight update for terminator with multiple fallthrough and
12 ; CHECK-NEXT: br label [[LOOP_PEEL_BEGIN:%.*]]
13 ; CHECK: loop.peel.begin:
14 ; CHECK-NEXT: br label [[LOOP_PEEL:%.*]]
16 ; CHECK-NEXT: [[X_PEEL:%.*]] = call i32 @get.x()
17 ; CHECK-NEXT: switch i32 [[X_PEEL]], label [[LOOP_LATCH_PEEL:%.*]] [
18 ; CHECK-NEXT: i32 0, label [[LOOP_LATCH_PEEL]]
19 ; CHECK-NEXT: i32 1, label [[LOOP_EXIT:%.*]]
20 ; CHECK-NEXT: i32 2, label [[LOOP_EXIT]]
21 ; CHECK-NEXT: ], !prof [[PROF0:![0-9]+]]
22 ; CHECK: loop.latch.peel:
23 ; CHECK-NEXT: br label [[LOOP_PEEL_NEXT:%.*]]
24 ; CHECK: loop.peel.next:
25 ; CHECK-NEXT: br label [[LOOP_PEEL2:%.*]]
27 ; CHECK-NEXT: [[X_PEEL3:%.*]] = call i32 @get.x()
28 ; CHECK-NEXT: switch i32 [[X_PEEL3]], label [[LOOP_LATCH_PEEL4:%.*]] [
29 ; CHECK-NEXT: i32 0, label [[LOOP_LATCH_PEEL4]]
30 ; CHECK-NEXT: i32 1, label [[LOOP_EXIT]]
31 ; CHECK-NEXT: i32 2, label [[LOOP_EXIT]]
32 ; CHECK-NEXT: ], !prof [[PROF1:![0-9]+]]
33 ; CHECK: loop.latch.peel4:
34 ; CHECK-NEXT: br label [[LOOP_PEEL_NEXT1:%.*]]
35 ; CHECK: loop.peel.next1:
36 ; CHECK-NEXT: br label [[LOOP_PEEL_NEXT5:%.*]]
37 ; CHECK: loop.peel.next5:
38 ; CHECK-NEXT: br label [[ENTRY_PEEL_NEWPH:%.*]]
39 ; CHECK: entry.peel.newph:
40 ; CHECK-NEXT: br label [[LOOP:%.*]]
42 ; CHECK-NEXT: [[X:%.*]] = call i32 @get.x()
43 ; CHECK-NEXT: switch i32 [[X]], label [[LOOP_LATCH:%.*]] [
44 ; CHECK-NEXT: i32 0, label [[LOOP_LATCH]]
45 ; CHECK-NEXT: i32 1, label [[LOOP_EXIT_LOOPEXIT:%.*]]
46 ; CHECK-NEXT: i32 2, label [[LOOP_EXIT_LOOPEXIT]]
47 ; CHECK-NEXT: ], !prof [[PROF2:![0-9]+]]
49 ; CHECK-NEXT: br label [[LOOP]], !llvm.loop [[LOOP3:![0-9]+]]
50 ; CHECK: loop.exit.loopexit:
51 ; CHECK-NEXT: br label [[LOOP_EXIT]]
53 ; CHECK-NEXT: ret void
55 ; DISABLEADV-LABEL: @test()
56 ; DISABLEADV-NEXT: entry:
57 ; DISABLEADV-NEXT: br label %loop
59 ; DISABLEADV-NEXT: %x = call i32 @get.x()
60 ; DISABLEADV-NEXT: switch i32 %x, label %loop.latch [
61 ; DISABLEADV-NEXT: i32 0, label %loop.latch
62 ; DISABLEADV-NEXT: i32 1, label %loop.exit
63 ; DISABLEADV-NEXT: i32 2, label %loop.exit
64 ; DISABLEADV-NEXT: ], !prof !0
65 ; DISABLEADV: loop.latch:
66 ; DISABLEADV-NEXT: br label %loop
67 ; DISABLEADV: loop.exit:
68 ; DISABLEADV-NEXT: ret void
74 %x = call i32 @get.x()
75 switch i32 %x, label %loop.latch [
76 i32 0, label %loop.latch
77 i32 1, label %loop.exit
78 i32 2, label %loop.exit
88 !0 = !{!"branch_weights", i32 100, i32 200, i32 20, i32 10}
91 ; CHECK: [[PROF0]] = !{!"branch_weights", i32 100, i32 200, i32 20, i32 10}
92 ; CHECK: [[PROF1]] = !{!"branch_weights", i32 90, i32 180, i32 20, i32 10}
93 ; CHECK: [[PROF2]] = !{!"branch_weights", i32 80, i32 160, i32 20, i32 10}
94 ; CHECK: [[LOOP3]] = distinct !{!3, !4, !5}
95 ; CHECK: [[META4:![0-9]+]] = !{!"llvm.loop.peeled.count", i32 2}
96 ; CHECK: [[META5:![0-9]+]] = !{!"llvm.loop.unroll.disable"}