<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/135285>135285</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[DirectX] Intrinsic `usub.sat` is preventing the generation of legal DXIL
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
farzonl
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
farzonl
</td>
</tr>
</table>
<pre>
Earlier passes are performaing analysis and replacing intrinsics with `usub.sat`
One example:
one replacement is umax(X, C) + C with usub.sat(X, C)
https://github.com/llvm/llvm-project/blob/1d8966e2465364dca8aea71d9331d46a0e908265/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp#L997-L1001
That means we need to legalize usub.sat. Instead of trying to reverse the transformation because there are many the plan will be to emit what the behavior of usub.sat will be.
AC:
Legalize `usub.sat`
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUk8FvqzgQxv8acxk1MjYQOHBIk41UKdIetodexzAJXhkb2SZp-tevDEn39d3eCTFjfv5mvg8MQV8sUcvKVybEGf2Xs4YJwcpDhnMcnG8fxUy5_t7-hd5o8jBhCBQAPQFM5M_Oj6jtBdCiuQcdAG0PniaDXSqDttFrG3QX4KbjAKzic5jVJmBkFWd8x_jub0tAnzhOhphMBWfpwaCRbAQdYB7xk4n6g4k97JlogIlX2K_Mb-CP_oIeYpxCgoojE8eLjsOsNp0bmTgac30-Xibv_qUuMnFUxikmjnlfN1VFoqhKWRV9hzUSbvO-kTLviwo5NbwWVfkLR6fv3j3akJYSmDi-2RD3blTa0s-3Xd__k3RMExPy1DTbl1POeb5Kfh8wwkhoA9wILFEP0YGhCxr9Rd_DbiABCXtwZ4j-nrYdHXi6kg8EcSCITzEYtbOgqMN5bXlaHBzR3peTk0ELN20MKEoUGnWEWxKSuooGvGrn003P65-nN6vo3X517vSU-dPnrG9l38gGM2rzbVFImfO8yIaWSykwF4rXglS3bSqqa0V9R7xq6vrcZboVXJS8yHPOhZTFpqwJeZerQmLdy7xjBacRtdkkHzbOXzIdwkxtLktRl5lBRSY8Ym7pBkv3EXTfLu6r-RJYwY0OMfyPiTqa5f84aE9d_GDlAd6eaf5tvpTQKa3exsWHgeBClvy6eHde7YPDx9spm71p_ziWi-qUqcdY11b8FwAA__9asjnr">