Files
TheRock/compiler/amd-llvm/llvm/test/Transforms/LoopUnroll/branch-weights-freq/peel-last-iteration-no-guard.ll
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

88 lines
2.9 KiB
LLVM

; Check that the loop body frequency is maintained when LoopPeel both:
; - Peels one unconditional iteration after the loop.
; - Does not add a guard to sometimes skip the remaining loop because it has
; proven the original loop always executes at least two iterations, which
; become the initial iteration and the peeled iteration.
; DEFINE: %{exitWeight} =
; DEFINE: %{loopWeight} =
; DEFINE: %{loopFreqOld} =
; DEFINE: %{loopFreqNew} =
; DEFINE: %{run} = \
; DEFINE: cp %s %t.ll && chmod +w %t.ll && \
; DEFINE: echo '!0 = !{!"branch_weights", i32 %{exitWeight}, ' \
; DEFINE: 'i32 %{loopWeight}}' >> %t.ll && \
; DEFINE: opt -p "print<block-freq>,loop-unroll,print<block-freq>" \
; DEFINE: -unroll-full-max-count=0 -S %t.ll 2>&1 | \
; DEFINE: FileCheck -DLOOP_FREQ_OLD='%{loopFreqOld}' \
; DEFINE: -DLOOP_FREQ_NEW='%{loopFreqNew}' %s
; Branch weights give the original loop 10 iterations. We expect that
; loopFreqOld = loopFreqNew + 1.
; REDEFINE: %{exitWeight} = 1
; REDEFINE: %{loopWeight} = 9
; REDEFINE: %{loopFreqOld} = 10.0
; REDEFINE: %{loopFreqNew} = 9.0
; RUN: %{run}
; Branch weights give the original loop 2 iterations. We expect that
; loopFreqOld = loopFreqNew + 1.
; REDEFINE: %{exitWeight} = 1
; REDEFINE: %{loopWeight} = 1
; REDEFINE: %{loopFreqOld} = 2.0
; REDEFINE: %{loopFreqNew} = 1.0
; RUN: %{run}
; Branch weights give the original loop 1 iteration, but LoopPeel proved it has
; at least 2. There is no loop probability that produces a frequency below 1,
; so the original total frequency cannot be maintained.
; REDEFINE: %{exitWeight} = 1
; REDEFINE: %{loopWeight} = 0
; REDEFINE: %{loopFreqOld} = 1.0
; REDEFINE: %{loopFreqNew} = 1.0
; RUN: %{run}
; Branch weights say the original loop is infinite, maximizing the frequency,
; so LoopPeel does not try to decrement it.
; REDEFINE: %{exitWeight} = 0
; REDEFINE: %{loopWeight} = 1
; REDEFINE: %{loopFreqOld} = 2147483647.8
; REDEFINE: %{loopFreqNew} = 2147483647.8
; RUN: %{run}
; Everything other than loop should be 1.0 because it is reached once.
;
; CHECK: block-frequency-info: test
; CHECK-NEXT: - entry: float = 1.0,
; CHECK-NEXT: - loop: float = [[LOOP_FREQ_OLD]],
; CHECK-NEXT: - exit: float = 1.0,
;
; CHECK: block-frequency-info: test
; CHECK-NEXT: - entry: float = 1.0,
; CHECK-NEXT: - loop: float = [[LOOP_FREQ_NEW]],
; CHECK-NEXT: - exit.peel.begin: float = 1.0,
; CHECK-NEXT: - loop.peel: float = 1.0,
; CHECK-NEXT: - exit.peel.next: float = 1.0,
; CHECK-NEXT: - loop.peel.next: float = 1.0,
; CHECK-NEXT: - exit: float = 1.0,
declare void @f(i32)
define void @test() {
entry:
br label %loop
loop:
%i = phi i32 [ 0, %entry ], [ %inc, %loop ]
%isLast = icmp eq i32 %i, 20
%sel = select i1 %isLast, i32 1, i32 0
call void @f(i32 %sel)
%inc = add i32 %i, 1
%isLast1 = icmp eq i32 %i, 20
br i1 %isLast1, label %exit, label %loop, !prof !0
exit:
ret void
}