Files
TheRock/compiler/amd-llvm/llvm/test/Transforms/LoopUnroll/AMDGPU/scev-mul-expansion-cost.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

41 lines
1.7 KiB
LLVM

; RUN: opt -S -passes=loop-unroll -unroll-runtime < %s | FileCheck %s
; The trip count SCEV for "for (i = start; i < end; i++)" is
; (-1 * start) + end. The SCEV expansion cost model should recognize that
; (-1 * X) is expanded as a negate (sub 0, X), not a real multiply. On
; targets where i32 mul is expensive (e.g. AMDGPU quarter-rate), the old
; cost model would over-count this as a mul (cost 4) exceeding the default
; budget of 4, and reject runtime unrolling. With the fix, it's costed as
; a sub (cost 1), well within budget.
; AMDGPU is used because its i32 mul has a cost of 4,
; making the over-counting observable against the default budget of 4.
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-p9:192:256:256:32-ni:7:8:9"
target triple = "amdgcn-amd-amdhsa"
; CHECK-LABEL: @offset_start_loop
; The loop should be runtime-unrolled 8x (prologue + main unrolled body).
; CHECK: %xtraiter = and i32 %{{.*}}, 7
; CHECK: loop.prol:
; CHECK: loop:
; CHECK: %iv.next.7 = add nsw i32 %iv, 8
define void @offset_start_loop(ptr addrspace(1) %out, ptr addrspace(1) %in, i32 %start, i32 %end) {
entry:
%cmp = icmp slt i32 %start, %end
br i1 %cmp, label %loop, label %exit
loop:
%iv = phi i32 [ %start, %entry ], [ %iv.next, %loop ]
%idx = sext i32 %iv to i64
%gep.in = getelementptr inbounds float, ptr addrspace(1) %in, i64 %idx
%val = load float, ptr addrspace(1) %gep.in, align 4
%gep.out = getelementptr inbounds float, ptr addrspace(1) %out, i64 %idx
store float %val, ptr addrspace(1) %gep.out, align 4
%iv.next = add nsw i32 %iv, 1
%cond = icmp slt i32 %iv.next, %end
br i1 %cond, label %loop, label %exit
exit:
ret void
}