From dc8a39037bf35fa1a26e17a2eba08b3e301f8191 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. 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: --- .pick_status.json | 2 +- src/compiler/spirv/vtn_opencl.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index bee808c8ef7..574d91e176e 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -584,7 +584,7 @@ "description": "vtn/opencl: flush denorms for cbrt()", "nominated": false, "nomination_type": 0, - "resolution": 4, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/compiler/spirv/vtn_opencl.c b/src/compiler/spirv/vtn_opencl.c index 043d61bb214..3f16685fb2e 100644 --- a/src/compiler/spirv/vtn_opencl.c +++ b/src/compiler/spirv/vtn_opencl.c @@ -725,6 +725,13 @@ 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) { + ret = nir_fcanonicalize(nb, ret); + } + return ret; }