From d249e7ddacfd741afb3e6fa3e9179390375c2b11 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Tue, 15 Apr 2025 10:01:32 -0500 Subject: [PATCH] nak: Lower 64-bit shifts in NIR on Kepler A and earlier SHF is introduced on Kepler B. Without it, there's nothing we can do that's more efficient than NIR's lowering. Part-of: --- src/nouveau/compiler/nak/api.rs | 3 +++ src/nouveau/compiler/nak/hw_tests.rs | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/nouveau/compiler/nak/api.rs b/src/nouveau/compiler/nak/api.rs index 7e40cf4a4be..fe8ea3fb2ad 100644 --- a/src/nouveau/compiler/nak/api.rs +++ b/src/nouveau/compiler/nak/api.rs @@ -156,6 +156,9 @@ fn nir_options(dev: &nv_device_info) -> nir_shader_compiler_options { | nir_lower_shift64 | nir_lower_imul_2x32_64 | nir_lower_conv64); + if dev.sm < 32 { + op.lower_int64_options |= nir_lower_shift64; + } op.lower_ldexp = true; op.lower_fmod = true; op.lower_ffract = true; diff --git a/src/nouveau/compiler/nak/hw_tests.rs b/src/nouveau/compiler/nak/hw_tests.rs index 8481cd79384..8f2a8cba441 100644 --- a/src/nouveau/compiler/nak/hw_tests.rs +++ b/src/nouveau/compiler/nak/hw_tests.rs @@ -918,6 +918,9 @@ fn test_op_popc() { #[test] fn test_op_shf() { let sm = &RunSingleton::get().sm; + if sm.sm() < 32 { + return; + } let types = [IntType::U32, IntType::I32, IntType::U64, IntType::I64]; @@ -1249,6 +1252,10 @@ fn test_isetp64() { #[test] fn test_shl64() { let run = RunSingleton::get(); + if run.sm.sm() < 32 { + return; + } + let invocations = 100; let mut b = TestShaderBuilder::new(run.sm.as_ref()); @@ -1283,6 +1290,10 @@ fn test_shl64() { #[test] fn test_shr64() { let run = RunSingleton::get(); + if run.sm.sm() < 32 { + return; + } + let invocations = 100; let cases = [true, false];