Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/xcl/src/gpu/dxil/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct KernelOptions {
/// Version of the direct translator's output, part of the on-disk translation cache's
/// identity (`recomp::pso`): bump it on any change that alters the emitted containers
/// (the `gpu/dxil` sources are not in build.rs's translator source hash).
pub const TRANSLATOR_VERSION: u32 = 4;
pub const TRANSLATOR_VERSION: u32 = 5;

/// `XCL_DIRECT_DXIL=1`: console compute shaders (and the kernel tests) go through this
/// translator, with the HLSL path as the fallback for what it cannot translate yet.
Expand Down
23 changes: 22 additions & 1 deletion crates/xcl/src/gpu/dxil/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ impl Module {
/// integers (DXC's shader-flag rules; `Fma` is flagged by its helper).
pub fn uses_double_extensions(&self) -> bool {
let Some(f64) = self.type_ids.get(&TypeDef::Double).copied() else { return false };
self.insts.iter().any(|d| match &d.op {
self.blocks.iter().flatten().map(|&i| &self.insts[i as usize]).any(|d| match &d.op {
Op::Bin(BinOp::UDiv | BinOp::SDiv, ..) => d.ty == f64,
Op::Cast(CastOp::FPToUI | CastOp::FPToSI, v, _) => self.value_ty(*v) == f64,
Op::Cast(CastOp::UIToFP | CastOp::SIToFP, _, t) => *t == f64,
Expand Down Expand Up @@ -1459,3 +1459,24 @@ impl Module {
self.globals.iter().filter(|g| g.addrspace == addrspace).map(|g| self.alloc_size_layout(g.ty, native16)).sum()
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn unreachable_conversion_does_not_require_double_extensions() {
let mut m = Module::new();
m.define_entry("main");
m.ret();
let dead = m.new_block();
m.set_block(dead);
let seven = m.i32c(7);
let double = m.f64();
m.cast(CastOp::SIToFP, seven, double);
m.ret();
assert!(m.uses_double_extensions());
m.optimize();
assert!(!m.uses_double_extensions());
}
}
Loading