https://github.com/wenju-he created https://github.com/llvm/llvm-project/pull/179406
This allows `sqrt(native_recip(x))` to fold to `rsqrt(x)` under -cl-fast-relaxed-math. >From e9f30843d2427fb784215a5dca62f42ce60301a0 Mon Sep 17 00:00:00 2001 From: Wenju He <[email protected]> Date: Tue, 3 Feb 2026 08:27:25 +0100 Subject: [PATCH] [libclc] Add contract flag to native_recip This allows `sqrt(native_recip(x))` to fold to `rsqrt(x)` under -cl-fast-relaxed-math. --- libclc/clc/lib/generic/math/clc_native_recip.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libclc/clc/lib/generic/math/clc_native_recip.inc b/libclc/clc/lib/generic/math/clc_native_recip.inc index e7246dc08a77c..4b878c2f39ab1 100644 --- a/libclc/clc/lib/generic/math/clc_native_recip.inc +++ b/libclc/clc/lib/generic/math/clc_native_recip.inc @@ -7,6 +7,6 @@ //===----------------------------------------------------------------------===// _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_native_recip(__CLC_GENTYPE val) { - _Pragma("clang fp reciprocal(on)"); +#pragma clang fp reciprocal(on) contract(fast) return 1.0f / val; } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
