<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/87367>87367</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[HLSL] Propose and discuss a holistic approach to math operations in HLSL
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:DirectX,
HLSL,
backend:SPIR-V
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
bogner
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
bogner
</td>
</tr>
</table>
<pre>
From @farzonl's investigation of #83882 it's become clear that splitting up HLSL math operations between generic LLVM intrinsics and special cased HLSL intrinsics is pretty unfortunate. We would prefer to avoid having to implement a large chunk of generic math operations in our own playground, and instead handle them generically in LLVM.
To do this, we should propose implementing the set of math intrinsics we're interested in as generic LLVM intrinsics, and work with the community to get to a solution that makes sense across the board.
A couple of things to note:
1. A chunk of the community has been reticent to accept new math intrinsics in the past (see https://discourse.llvm.org/t/math-intrinsics/67192, https://github.com/llvm/llvm-project/pull/79948, etc), but there have been discussions debating the split between libcalls and intrinsics for math for a very long time (https://discourse.llvm.org/t/rfc-canonicalize-libcalls-to-intrinsics/39697)
2. The proposal should discuss the full set of math operations we're interested in so that people understand the full picture when discussing this.
AC: This work item tracks sending the initial RFC and driving the conversation to an actionable conclusion.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVc2O4zYTfBr60rAhU_7TwQd_uzC-ABNgsTvY5EpRbYkZihTYTRvepw-atucn2QDJyZJIFquqq9uGyPUBca_W_1Nat7EPmJTWav15ZjIPMe1v32Zt7K77Y4ojqFV1MulHDF7pLYELZyR2vWEXA8QTKF3v6t1Og-OyoUUbRwTr0STgwTDQ5B2zCz3kCf7_9O0JRsMDxAlTQZEzfEEM0GPA5Cw8PX3_FVzg5AI5S2BCBzShdcaDNYTdDebdDkcwJWS-Qg6nmDgHw7iA3xAuMftOFk-YgCOYc3QdDOYshDiCGyePIwYGA96kHsEOObyItAedv9J1AWJOE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