Files
TheRock/compiler/amd-llvm/llvm/test/CodeGen/AArch64/udiv-const-optimization.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

62 lines
1.9 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=aarch64-unknown-linux | FileCheck %s
; Test optimization of 32-bit unsigned division by constants with 33-bit magic
; constants (IsAdd=true) on AArch64. The optimization uses the umulh instruction.
define i32 @udiv_by_7(i32 %x) nounwind {
; CHECK-LABEL: udiv_by_7:
; CHECK: // %bb.0:
; CHECK-NEXT: mov x8, #2684354560 // =0xa0000000
; CHECK-NEXT: mov w9, w0
; CHECK-NEXT: movk x8, #18724, lsl #32
; CHECK-NEXT: movk x8, #9362, lsl #48
; CHECK-NEXT: umulh x0, x9, x8
; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
; CHECK-NEXT: ret
%div = udiv i32 %x, 7
ret i32 %div
}
define i32 @udiv_by_19(i32 %x) nounwind {
; CHECK-LABEL: udiv_by_19:
; CHECK: // %bb.0:
; CHECK-NEXT: mov x8, #1476395008 // =0x58000000
; CHECK-NEXT: mov w9, w0
; CHECK-NEXT: movk x8, #17246, lsl #32
; CHECK-NEXT: movk x8, #3449, lsl #48
; CHECK-NEXT: umulh x0, x9, x8
; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
; CHECK-NEXT: ret
%div = udiv i32 %x, 19
ret i32 %div
}
define i32 @udiv_by_21(i32 %x) nounwind {
; CHECK-LABEL: udiv_by_21:
; CHECK: // %bb.0:
; CHECK-NEXT: mov x8, #939524096 // =0x38000000
; CHECK-NEXT: mov w9, w0
; CHECK-NEXT: movk x8, #49932, lsl #32
; CHECK-NEXT: movk x8, #3120, lsl #48
; CHECK-NEXT: umulh x0, x9, x8
; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
; CHECK-NEXT: ret
%div = udiv i32 %x, 21
ret i32 %div
}
; Test non-optimized case
define i32 @udiv_by_3(i32 %x) nounwind {
; CHECK-LABEL: udiv_by_3:
; CHECK: // %bb.0:
; CHECK-NEXT: mov w8, #43691 // =0xaaab
; CHECK-NEXT: movk w8, #43690, lsl #16
; CHECK-NEXT: umull x8, w0, w8
; CHECK-NEXT: lsr x0, x8, #33
; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0
; CHECK-NEXT: ret
%div = udiv i32 %x, 3
ret i32 %div
}