[libclc] [libclc] Enable -ffp-contract=fast compile option for math native_* functions (PR #153137)

Wenju He via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 11 21:51:58 PDT 2025


https://github.com/wenju-he created https://github.com/llvm/llvm-project/pull/153137

According to OpenCL spec, native_* functions have implementation-defined accuracy and typically have better performance. We can enable floating- point contraction optimizations for them.

>From 719a6914321afc04b44fda1a7ba38ecffa95d080 Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Tue, 12 Aug 2025 06:27:11 +0200
Subject: [PATCH] [libclc] Enable -ffp-contract=fast compile option for math
 native_* functions

According to OpenCL spec, native_* functions have implementation-defined
accuracy and typically have better performance. We can enable floating-
point contraction optimizations for them.
---
 libclc/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 756e097dcf123..55072785e6f79 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -304,7 +304,7 @@ set_source_files_properties(
   ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_sin.cl
   ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_sqrt.cl
   ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/math/native_tan.cl
-  PROPERTIES COMPILE_OPTIONS -fapprox-func
+  PROPERTIES COMPILE_OPTIONS "-fapprox-func;-ffp-contract=fast"
 )
 
 enable_testing()



More information about the cfe-commits mailing list