Repository navigation
fix(mir-importer): lower is_val_statically_known to false - #1359
Open
Arthur031221 wants to merge 1 commit into
Open
Arthur031221 wants to merge 1 commit into
Arthur031221 wants to merge 1 commit into
Conversation
libcore's integer checked_pow, overflowing_pow and checked_ilog branch on core::intrinsics::is_val_statically_known, and integer pow, ilog, saturating_pow and wrapping_pow reach it through them. The importer had no arm for the intrinsic, so a kernel calling any of these failed to compile with "rustc intrinsic `std::intrinsics::is_val_statically_known` is not yet supported on the device". The intrinsic may return false for any argument, so emit a constant false and let libcore take its general path. The checked_arith example gains a pow_family kernel checked against the host results. Signed-off-by: Arthur031221 <levi74108520963@gmail.com>
Arthur031221
force-pushed
the
fix/is-val-statically-known
branch
from
October 2, 2026 08:16
3b95bbb to
12997f7
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.
Summary
A kernel that calls integer
pow,checked_pow,overflowing_pow,saturating_pow,wrapping_pow,ilogorchecked_ilogfails to compile today, with:libcore's
checked_pow,overflowing_powandchecked_ilogbranch onis_val_statically_known, and the other functions above call one of those three (u32::powfails inoverflowing_pow,u32::iloginchecked_ilog). The importer has no arm for the intrinsic, so it hits the generic rejection.f32::powiis not affected.The intrinsic is allowed to return
falsefor any argument, so this lowers it to a constantfalseand libcore takes its general path.With a constant
false, a base known at compile time (such as2u32.pow(n)) takes the general loop instead of libcore's shift shortcut. Keeping the shortcut would mean lowering tollvm.is.constant, which nothing in the lowering emits today, so I left that out of this change.Fixes #1358.
Changes
mir-importer: dispatchcore::intrinsics::is_val_statically_known(and thestd::spelling) next tocold_path, through a newemit_bool_constant_intrinsichelper that writes a constanti1to the call destination and branches to the target block.checked_arithexample: newpow_familykernel coveringpowonu64,checked_powoni32,overflowing_powonu32,saturating_powonu8,wrapping_powoni16,ilog(10)andchecked_ilog(10), compared against the same expressions on the host. Inputs include a zero exponent, negative bases with odd exponents, and overflowing cases (7^12 and 46341^2 fori32).slice::fillon integers wider than a byte also callsis_val_statically_known(u8andi8go straight towrite_bytes). With this change it gets past that point, but still fails later onwrite_bytes, which the device does not support yet. That is a separate gap and is not touched here.Testing
cargo oxide run checked_arithon an RTX 5090: printsPASS: integer pow family and ilog, also withCUDA_OXIDE_NO_OPT=1. With the twomir-importerfiles restored frommain, the example fails to compile with the error above.The
testrecipe'scargo test --all-targetspackage list: 3908 passed, 0 failed, 10 ignored, same as onmain. Thetest-cudarecipe: 1505 passed, 0 failed, 1 ignored.cargo oxide fmt --check, workspace and backend clippy with-D warnings, and clippy inexamples/checked_arithpass. Thecheck-guardsscripts pass exceptcheck-example-license-policy.sh, which needscargo-denyand I don't have it installed. This change adds no dependencies.just checkpasses (the local mirror of CI: fmt, clippy, tests, guards, docs)cargo oxide run <example>passes, orscripts/smoketest.sh -o '^<example>$'New example added (if applicable)
Checklist
git commit -s)