-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance Intrinsic::fmuladd translation. #2162
Comments
fmuladd should be translated to fmuladd as it is. It is likely the lack of support of the translation in spirv spec so that it is translate to mad. |
That is correct. We don't have a direct equivalent of I'm not entirely sure if we only need to use Tagging @bashbaug for awareness as well |
I agree with @AlexeySachkov - for full profile devices the OpenCL LLVM: "The ‘llvm.fmuladd.*’ intrinsic functions represent multiply-add expressions that can be fused if the code generator determines that (a) the target instruction set has support for a fused operation, and (b) that the fused operation is more efficient than the equivalent, separate pair of mul and add instructions." SPIR-V: "OpExtInst mad - Implemented either as a correctly rounded fma, or as a multiply followed by an add, both of which are correctly rounded." We have an internal Khronos tracker to improve this (SPIR-V issue 409) and support |
-cl-mad-enable is off by default, however ReplaceLLVMFmulAddWithOpenCLMad is true by default https://github.com/KhronosGroup/SPIRV-LLVM-Translator/blob/main/include/LLVMSPIRVOpts.h#L244C8-L244C40, which seems not consistent. Intrinsic::fmuladd should be translated into mad when function attribute "less-precise-fpmad" = "true" which indicates -cl-mad-enable is specified. When "less-precise-fpmad" = "false" or there is no "less-precise-fpmad", translate it into a pair of fmul + fadd.
Can we remove ReplaceLLVMFmulAddWithOpenCLMad uses and let only "less-precise-fpmad" determine how to translate fmuladd?
@AlexeySachkov, @MrSidims, @svenvh , do you think is ReplaceLLVMFmulAddWithOpenCLMad still needed and what's your opinion for above comments? Thanks very much. #2163 is drafted and need further discussion.
The text was updated successfully, but these errors were encountered: