<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/68315>68315</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Compute v_madmk with all constant operands at compile time
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:AMDGPU,
            missed-optimization
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          kosarev
      </td>
    </tr>
</table>

<pre>
    The output for the `llvm/test/CodeGen/AMDGPU/amdgpu-codegenprepare-idiv.ll` test currently reads like we fail to fold the `v_madmk_f32` instruction despite all operands being constant. See a related discussion in <https://reviews.llvm.org/D74435#inline-1549598>.
```
define amdgpu_kernel void @udiv_i64_oddk_denom(ptr addrspace(1) %out, i64 %x) {
...
; GFX9-LABEL: udiv_i64_oddk_denom:
; GFX9:       ; %bb.0:
; GFX9-NEXT:    v_mov_b32_e32 v0, 0x4f176a73
; GFX9-NEXT:    v_mov_b32_e32 v1, 0x4f800000
; GFX9-NEXT:    v_madmk_f32 v0, v1, 0x438f8000, v0
```


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMU8GOpDYQ_ZriUmpkbKDhwKGne5jLJoqUjbQ3ZHDR7bSxkW2Y3Xx9BDO9q1VG0VoIycV7PJfrPRmCvlqiBoonKC6JXOLN-ebugvS0Jr1T35rPN0K3xHmJODqP8UYIJTNmnYC3kUIE3p6doheywNvTb5eXP_4C3spJXeflMDhFV7Kzp1l6Omil19QYKBluVBwW78lG8w09SRXQ6DvhK-EotcHocHRGPSTXbpJqunej4Btf2xD9MkTtLCoKs46E0hh0M3lpVcCetL3i4GyI0sYU_yRCiZ6MjKRQ6TAsIWxsbRHE-RbjHECcgLfAW0-rpteQbn2mzl-Bt5djnosCuNDWaEuHrMjroq5APKfALsBOULL3Z98qGrUlfLuI7k7eksHVaYWQs0XptdNl3jml7p0i6ybg1Rw9SqV8mOVAwKsMeI3AC7dE4GfUZb7tvu7V49ObTJo-5MUTvrRf6sOn09PzJxAn_EhEnH5Gb7i3tVWAF32fsv-gDr8_f_n8Dl27ya1dL3hHguPKtpOxr_mYHUt5FL_Myx68im3rf3mPub-rfeeKamfvNfbhEN7eiWqEqkUtE2qysi6LrKx5mdwaNnKW9-NQ07HvWZaNrDoeh6EYSQ0soyzRDWdcZIwVWZ5zVqbjUPacRN2XvBJqHCBnNEltvjsl0SEs1JSVyIrEyJ5M2OPFeS-HO1kF4vRICQd-Bs4nHQKpg5ujnvQ_crP09q24JL7Zfnvol2uAnBkd4g9LJlFHQ83ZTfMS6XFN-KrjbQ_Cw_k_EiEjDm6atSGMeqJk8ab52fZXHW9Lnw6bG9v3jO8nmL37m4Yt63t7AXi7d_hvAAAA__-VvkwI">