KhronosGroup / KhronosGroup/SPIRV-LLVM-Translator

Enhance Intrinsic::fmuladd translation.

Open
#2,162 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
LLVM
Stars
625
Forks
279
Avg merge
3d 5h
Merged PRs (30d)
34

Description

-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. https://github.com/KhronosGroup/SPIRV-LLVM-Translator/pull/2163 is drafted and need further discussion.

Contributor guide

Open the contributing guide

Research direction

Start with include/LLVMSPIRVOpts.h and the uses of ReplaceLLVMFmulAddWithOpenCLMad, then trace the Intrinsic::fmuladd translation path. Review the drafted pull request #2163 and the existing discussion before deciding whether the less-precise-fpmad attribute alone should control translation. Done means the behavior is agreed, implemented, and covered by the relevant translator tests.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.