[clang] [Clang][OpenCL] Enable MAD contraction under the `-cl-mad-enable` flag (PR #245782)

Victor Mustya via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 24 14:00:55 PST 2026


vmustya wrote:

> This is not what contract or -cl-mad-enable means. There are already ample controls for contraction, which allows increasing precision.

According to the [OpenCL spec](https://registry.khronos.org/OpenCL/specs/unified/html/OpenCL_API.html#optimization-options):
> `-cl-mad-enable`
> Allow `a * b + c` to be replaced by a mad instruction. The mad instruction may compute `a * b + c` with reduced accuracy in the embedded profile. See the OpenCL C or OpenCL SPIR-V Environment specification for accuracy details. On some hardware the mad instruction may provide better performance than the expanded computation.

@arsenm , to me it looks like the `-cl-mad-enable` enables the contraction for the `fmul` and `fadd` operations. On the LLVM IR the `contract` flag is used exactly for that purpose.

https://github.com/llvm/llvm-project/pull/245782


More information about the cfe-commits mailing list