From 6971c8e2eb8ef5aa9bff74fded82776b8d5a3ea4 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Tue, 10 Feb 2026 02:03:24 +0100 Subject: [PATCH] vtn/opencl: flush denorms for cbrt() libclc doesn't so we have to. fixes math_brutefore cbrt on Iris. This uses an exact fmul 1.0 instead of fcanonlize, because the latter got added with 26.0. Co-authored-by: Alyssa Rosenzweig Signed-off-by: Alyssa Rosenzweig Reviewed-by: Alyssa Rosenzweig Reviewed-by: Karol Herbst (cherry picked from commit af954427bf7f008f065caed38f9ed5214b0b305a) Part-of: --- src/compiler/spirv/vtn_opencl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/compiler/spirv/vtn_opencl.c b/src/compiler/spirv/vtn_opencl.c index 103d4742009..a74d5d84c41 100644 --- a/src/compiler/spirv/vtn_opencl.c +++ b/src/compiler/spirv/vtn_opencl.c @@ -725,6 +725,16 @@ handle_special(struct vtn_builder *b, uint32_t opcode, if (!ret) vtn_fail("No NIR equivalent"); + /* libclc's cbrt() implementation fails to flush subnormal numbers to zero + * even when flush-to-zero is required. Manually flush its output. + */ + if (opcode == OpenCLstd_Cbrt) { + const bool save_exact = nb->exact; + nb->exact = true; + ret = nir_fmul_imm(nb, ret, 1.0); + nb->exact = save_exact; + } + return ret; }