Repository navigation
fix(mir-lower): lower redux.sync results to signless integers - #1264
Merged
nihalpasham merged 2 commits intoSep 18, 2026
Merged
Conversation
`convert_redux` declared the `llvm_nvvm_redux_sync_*` intrinsic with the
dialect op's result type unconverted, so an integer reduction was declared
as returning `ui32`/`si32` while its operands were already signless `i32`.
A result that only feeds a store went unnoticed, but a device function
returning the reduction directly failed verification:
ReturnOp operand type does not match the function's result type
This is the lowering failure blocking the `warp_reduce` fast path in NVIDIA#811.
Convert the result type with `convert_type`, as the other intrinsic
converters do. The fix covers all 16 `redux.sync` ops that share
`convert_redux`.
Adds a lowering test returning each integer redux op (and four f32
controls) from a device function, and a `redux_minmax` kernel that reduces
through out-of-line helpers so the GPU-less example compile gate covers
the real Rust shape.
Signed-off-by: sachin <[email protected]>
Signed-off-by: nihalp <[email protected]>
nihalpasham
force-pushed
the
fix/811-warp-reduce-lowering
branch
from
September 18, 2026 03:49
a18f1af to
5a3653e
Compare
nihalpasham
reviewed
Sep 18, 2026
Collaborator
There was a problem hiding this comment.
I kept the shared result-type conversion and added a few checks around it:
- Covered all 16 reduction operations, including unchanged float results.
- Checked the exact intrinsic and value/mask order so a different call cannot satisfy the regression.
- Rebasing and signing preserved the contributor's original commit and sign-off.
All 429 MIR-lower tests, formatting, strict Clippy and docs pass. redux_minmax also passes on RTX 5090 with zero memcheck/synccheck errors, including both helper-returned results.
This removes the return-type blocker reported in #811; architecture selection and warp_reduce remain separate. Modern libNVVM also runs correctly. Legacy libNVVM retains its existing unresolved-redux-intrinsic failure, reproduced with the original direct kernels.
Checked at 5a3653e3. Hosted CI also passes on this head.
nihalpasham
approved these changes
Sep 18, 2026
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.
What this fixes
Device helpers can return integer
redux.syncresults directly. The lowerer previously kept the result's Rust signedness after converting the function signature to LLVM's signless integer type.What we fixed
redux_minmax.Verification
Checked at
5a3653e3:redux_minmaxpasses on RTX 5090, SM120, through LLVM NVPTX and modern libNVVM. Helper results are-16and4294967295; memcheck and synccheck both report zero errors.This removes the reported lowering blocker in #811. The architecture selection and
warp_reduceAPI work remain separate; #811 remains open for that work. Float operations were checked in lowering, not on hardware.Known backend limit
Legacy libNVVM still emits unresolved
llvm.nvvm.redux.sync.*calls. The existing direct-reduction kernels fail the same CUDA 13.0 PTX assembly check after removing the new helpers; this is an existing intrinsic-support gap, separate from the return-type fix. LLVM NVPTX and modern libNVVM execute correctly.