Repository navigation
Description
Summary
The target feature scan splits LLVM IR on ; and calls each piece a "statement". In LLVM IR ; starts a comment, so a whole module is typically one or two pieces — and every predicate that asks for two things in the same "statement" is really asking whether both appear anywhere in the module.
Evidence
The IR cargo oxide build redux_minmax writes beside the example (a build output, not a tracked file; after the mono-repo move it lands at cuda-oxide/crates/rustc-codegen-cuda/examples/redux_minmax/redux_minmax.ll):
bytes: 3093 lines: 98 semicolon-chunks: 2
98 lines, one semicolon. Redux reaches the IR as NVVM intrinsic declarations, not as inline PTX:
declare i32 @llvm.nvvm.redux.sync.min(i32, i32) #0
declare i32 @llvm.nvvm.redux.sync.umin(i32, i32) #0What it costs
contains_redux_f32_features (detect.rs:99) is the one I tripped:
contents.split(';')
.any(|statement| statement.contains("redux.sync") && statement.contains(".f32"))A module of mine uses integer warp_reduce (so integer redux.sync declarations) and, in a different kernel, ordinary f32 shuffles. No f32 redux anywhere:
redux mentions in the IR: redux.sync.add, .and, .max, .min, .or, .umax, .umin, .xor
f32 redux: none
It is still rejected:
CUDA target sm_80 cannot lower detected feature ReduxF32 + Sm80;
cuda-oxide requires a target compatible with sm_100a for this module
Because the 42 KB module splits into 2 chunks, and in the chunk that matches, redux.sync is at line 768 and .f32 at line 1315 — 547 lines apart, in unrelated code.
So a module that mixes integer warp reductions with any float work is pushed from sm_80 to sm_100a and refuses to build.
Scope
21 call sites use contents.split(';'). Single-substring predicates are unaffected — a substring is present or not regardless of how the text is cut. The conjunctive ones are the exposed set, e.g.:
contains_redux_f32_features—redux.sync&&.f32contains_multimem_blackwell_features— multimem && (.e4m3|.e5m2|.acc::f16)contains_cluster_scoped_memory_features—!multimem.&&.cluster.&& (ld.|st.|atom.|red.)
The negation in the last one is worth calling out: at module granularity, one multimem. anywhere suppresses cluster-memory detection for the whole module — a false negative, which fails the other way.
Suggested fix
Split on newlines as well as ;. LLVM IR is line-oriented, and where PTX text does appear inline it sits within one line (multi-instruction asm templates escape their newlines as \0A, which is not a newline in the file text). So this is strictly finer than the current split: it can remove false positives and cannot introduce false negatives.
I have the fix and a regression test built from the module above (integer redux declarations plus f32 ops on separate lines must not report ReduxF32; a real declare float @llvm.nvvm.redux.sync.fmin.f32 must). Happy to put it up — it blocks #811, whose warp_reduce fast path is integer-only and lands in modules that also do float work.
Environment
cuda-oxide at b9847e95; detected on an A10G (sm_86) build, reproducible from the IR text alone.
Activity
vyncint commentedon Sep 19, 2026
Correcting the scope of my own report before anyone acts on it.
The
multimem.negation I listed under "Scope" is not demonstrated, and my first attempt at a test for it was green for the wrong reason twice: once because.shared::clustersetsClusteron its own, and then, after I removed that, because the two inline-asm strings each end in a;inside the string literal — so a;-only split does separate them.That is the part I had wrong, and it narrows the bug usefully:
;, and the existing split works.redux.syncis exactly that: it comes through NVVM intrinsic declarations.So the confirmed case is the conjunction over declaration-shaped text, which is what
contains_redux_f32_featuresmatches, and what rejected a real sm_80 module of mine. The other conjunctive predicates are exposed in principle by the same granularity, but I have no reproducer for them and should not have implied otherwise.The fix and its regression test are unchanged — splitting on newlines as well as
;is still strictly finer, and the redux test fails without it and passes with it.fix(codegen): match redux.sync's f32 form on the instruction, not on …