<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/88944>88944</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[SPIRV][HLSL] Implement integer (signed\unsigned) `mad` lowering
</td>
</tr>
<tr>
<th>Labels</th>
<td>
HLSL,
backend:SPIR-V
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
farzonl
</td>
</tr>
</table>
<pre>
The float case is already covered via fma
```asm
OpExtInst %v4float %1 Fma %12 %13 %14
```
Tests for float mad live here: https://github.com/llvm/llvm-project/blob/main/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/fmad.ll
This ticket is to track the integer cases of mad which just lower to a mul followed by an add.
https://shader-playground.timjones.io/94c522e7e01bba7e958d2a5bd4813993
scalar int case:
```hlsl
int foo(int a, int b, int c) {
return mad(a,b,c)
}
```
needs to be:
```asm
%4 = OpIMul %int %11 %12
%5 = OpIAdd %int %4 %13
```
scalar uint case:
```hlsl
uint foo(uint a, uint b, uint c) {
return mad(a,b,c)
}
```
needs to be:
```asm
%4 = OpIMul %uint %11 %12
%5 = OpIAdd %uint %4 %13
```
scalar uint4:
```hlsl
uint4 foo(uint4 a, uint4 b, uint4 c) {
return mad(a,b,c)
}
```
needs to be:
```asm
%4 = OpIMul %v4uint %11 %12
%5 = OpIAdd %v4uint %4 %13
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMld9vpDYQx_-a4cUKgsEs8MDDJlvaSFdd1Tvdu8HD4sTglX_sNf3rK0OSTaqVmvalJ61YY76MZz4evhbOqeNC1EJ5C-UhEcFPxrajsH-aRSe9kU_t14nYqI3wbBCOmHJMaEtCPrHBnMmSZGcl2DgLyA6Q7WGXbT_h5m3m8-mnP_z94jwDLM98iwVY5qybxTrA9VqsV_63MNvtV3LesdHY51RmIZlWZ2ITWYJizybvTw6KPWAH2B2Vn0KfDmYG7LQ-v_zdnKx5oMEDdr02PWA3C7VcNJ5cfHZnJP1Mcf7Lb_e_fwPsJu30jVq8VYtTgwPsxlnIVOvnbLckJ-WYV8Mj-YjJG-atGB6Zn4ipxdOR7MrQMTOuFXyf1DCxh-A80-Y72fiKYHPQbDQ6zkjWPzGxMCFl-nal99W6SUiyNyctno7WhEWmXs0PZiGXKgPYNXwoEamiLO97UVFT1hJF2Ute50XTFG8ju0FoYWO6a6pxjff7EUlsU1EzGgNYx5EAvFtf618GA2DDoLrd1MySD3aJdQPWUR2FUfO8QHW4uvMLkVxZ9leSee2x2DqcQXFgn0_3vwYd72MOsaPyrccuwvJFuJfyjZBvXXg1i3dwwkfohAue8MonvAIKPwKh8GFE4b8w4v_Eh78BxC-E-AUR_98ZnfnHKV201zklsi1kUzQioTav8gLrpmmqZGpzIhpkVma7Xfw063HgmZQ5NRJxqDFPVIsZ8oznu7wqi7xKeb0j3hT9UNV1kecF8IxmoXQanSw19pgo5wK1dd1wnmjRk3aryyP-8unLJ0AEvAPEXgyPtEgo9tHqbr7FB-Uhse1ql304OuCZVs67S2SvvF6PjM0dywOUt2vQ8sDu55OmmRb_6niA9XrISCjvwvI8jHu6y-Iu7rLN-9RyTILV7b828rXO6MhrqX8FAAD__1g867w">