Files
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

64 lines
2.4 KiB
MLIR

// RUN: mlir-opt --int-range-optimizations %s | FileCheck %s
// Verify that `IntegerRangeAnalysis` infers tight bounds for loop-carried
// values that are structurally bounded inside the loop body (via
// `arith.minsi`, `arith.andi`, etc.). Convergence is guaranteed by the
// per-state widening budget on `IntegerValueRangeLattice`; the budget is
// large enough that these naturally bounded ratchets reach a fixpoint
// without being widened to `[INT_MIN, INT_MAX]`.
// CHECK-LABEL: func @bounded_acc_for
// CHECK: test.reflect_bounds {smax = 10 : si32, smin = 0 : si32, umax = 10 : ui32, umin = 0 : ui32}
func.func @bounded_acc_for(%n: i32) -> i32 {
%c0 = arith.constant 0 : i32
%c1 = arith.constant 1 : i32
%c10 = arith.constant 10 : i32
%res = scf.for %i = %c0 to %n step %c1 iter_args(%acc = %c0) -> i32 : i32 {
%incr = arith.addi %acc, %c1 : i32
%clamped = arith.minsi %incr, %c10 : i32
scf.yield %clamped : i32
}
%r = test.reflect_bounds %res : i32
return %r : i32
}
// The `arith.cmpi slt, %acc, 100` should fold to `true` once the analysis
// proves the iter arg stays in `[0, 10]`, exposing a downstream
// optimization that the previous yield-based widening masked.
// CHECK-LABEL: func @bounded_acc_while
// CHECK: %[[TRUE:.*]] = arith.constant true
// CHECK: scf.condition(%[[TRUE]])
// CHECK: test.reflect_bounds {smax = 10 : si32, smin = 0 : si32, umax = 10 : ui32, umin = 0 : ui32}
func.func @bounded_acc_while() -> i32 {
%c0 = arith.constant 0 : i32
%c1 = arith.constant 1 : i32
%c10 = arith.constant 10 : i32
%c100 = arith.constant 100 : i32
%res = scf.while (%acc = %c0) : (i32) -> i32 {
%cond = arith.cmpi slt, %acc, %c100 : i32
scf.condition(%cond) %acc : i32
} do {
^bb0(%a: i32):
%incr = arith.addi %a, %c1 : i32
%clamped = arith.minsi %incr, %c10 : i32
scf.yield %clamped : i32
}
%r = test.reflect_bounds %res : i32
return %r : i32
}
// CHECK-LABEL: func @bounded_mask_for
// CHECK: test.reflect_bounds {smax = 15 : si32, smin = 0 : si32, umax = 15 : ui32, umin = 0 : ui32}
func.func @bounded_mask_for(%n: i32) -> i32 {
%c0 = arith.constant 0 : i32
%c1 = arith.constant 1 : i32
%c15 = arith.constant 15 : i32
%res = scf.for %i = %c0 to %n step %c1 iter_args(%acc = %c0) -> i32 : i32 {
%incr = arith.addi %acc, %c1 : i32
%masked = arith.andi %incr, %c15 : i32
scf.yield %masked : i32
}
%r = test.reflect_bounds %res : i32
return %r : i32
}