Repository navigation
constant_integer_bounds: bound Select by the union of its values - #9604
Open
alexreinking wants to merge 1 commit into
Open
alexreinking wants to merge 1 commit into
alexreinking wants to merge 1 commit into
Conversation
abadams
approved these changes
Oct 23, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## alexreinking/prefetch-fixes #9604 +/- ##
==============================================================
Coverage ? 72.95%
==============================================================
Files ? 263
Lines ? 82494
Branches ? 20179
==============================================================
Hits ? 60184
Misses ? 15914
Partials ? 6396 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
alexreinking
force-pushed
the
alexreinking/constant-bounds-select
branch
from
October 24, 2026 15:43
205a560 to
9e8a832
Compare
alexreinking
force-pushed
the
alexreinking/constant-bounds-select
branch
from
October 25, 2026 21:05
9e8a832 to
01bc902
Compare
alexreinking
changed the base branch from
alexreinking/arm-prefetch-line-size
to
alexreinking/prefetch-fixes
October 25, 2026 21:05
alexreinking
force-pushed
the
alexreinking/constant-bounds-select
branch
from
October 26, 2026 19:58
01bc902 to
beb12bb
Compare
bounds_helper had no case for Select, so any select fell through to the full bounds of its type. A select always evaluates to one of its two values, so the union of their constant bounds is a sound bound; the condition is ignored. The three-argument form of Call::if_then_else is handled the same way. This matters for code that decodes small integer codes via selects (e.g. ternary weights in quantized GGML kernels) and then needs constant_integer_bounds to prove that a subsequent integer sum can't overflow. Such code currently has to work around the missing case by substituting the selects with variables bound in a Scope. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
alexreinking
force-pushed
the
alexreinking/constant-bounds-select
branch
from
October 26, 2026 23:05
beb12bb to
045408f
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
constant_integer_boundshad no case forSelect, so a select fell through to the full bounds of its type. A select always evaluates to one of its two values, so this PR bounds it by the union of the two values' bounds (the condition is ignored). The three-argumentCall::if_then_elsegets the same treatment; the two-argument form, which has no else value, is unchanged.This matters for code that decodes small integer codes through selects and then needs
constant_integer_boundsto prove that a later integer sum can't overflow. The GGML app (#9511) does this for ternary (tq1_0) weights, and currently works around the gap by replacing each select with a variable bound in aScopeto the union of its values' bounds.correctness_constant_intervalgainstest_constant_integer_bounds_of_select(), which fails before this change and passes after it. It covers:select(x > 0, int(u8), -3)→ [-3, 255];int16x8) select;if_then_else.A comment in
correctness_struct_typethat saidbounds_helperhad no Select case is updated.Stacked on #9599.
Checklist
Tested on macOS arm64 with LLVM 22:
ctest -R 'correctness_(bound|bounds|constant_interval|struct_type|bits_known|lossless_cast|intrinsics|interval|many_inlined_selects|multi_way_select|tuple_select|popc_clz_ctz|overflow|simd_op_check_(arm|x86|wasm|hvx))|fuzz_lossless_cast': 39/39 passed.ctest -L correctness, excluding GPU and Hexagon tests: 618 of 621 passed.correctness_cross_compilationfailed because the local LLVM build has no Hexagon target.auto_schedule_no_*tests failed because the autoscheduler plugin wasn't built; both pass once it is.