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

    <tr>
        <th>Summary</th>
        <td>
            [AArch64][GlobalISel] Improve i128 mul generation
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:AArch64,
            llvm:globalisel
      </td>
    </tr>

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

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

<pre>
    i128 multiplies under GlobalISel could be producing more madds if it reassociated the add.
https://godbolt.org/z/Wr1r5ez1G

SDAG
```
 umulh   x8, x0, x2
        madd    x8, x0, x3, x8
        mul     x0, x0, x2
        madd    x1, x1, x2, x8
 ret
```

GISel
```
        mul     x9, x0, x3
        mul x8, x0, x2
        umulh   x10, x0, x2
        madd    x9, x1, x2, x9
        mov     x0, x8
        add     x1, x9, x10
 ret
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMU01vnDAQ_TXmYmVlG8PCwQfSFaucc-jZxgO4NXjlj1WaX1_Bsk1K0qgIjWXN4zHvaZ4MwQwzgEDFIypOmUxxdF5oeYVp8ABzppz-JQxlFZ6SjeZiDQScZg0en61T0j49g8WdS1ZjBfjinU6dmQc8OQ94kloHbHpsIvYgQ3CdkRE0jiNgqfUBkRMizRjjJaC8QaxFrB2cVs7Gg_MDYu0rYu13T30Br_R8g9_q86m530uyvesVpynZEWP8UiH2Db-QtbKtuT3LZHiPydda7ZDJrueG-ZqNrl26Yd6zeYifTnur58XGz9Xsx6j_GvgD5ivRf4yh_6Ol_qCl3iHd9b0zO982mjvDxkb-aUemRa7rvJYZCHrMKak4q47ZKHRdaVkTSinXSvaKy76sJJBS9j0QfcyMYIRxSklFS8758VCRjvO6h7JXfalojziBSRp7sPY6LXuVmRASCEqLgrLMSgU2rBlgTMnuJ8wa5U3T-G4sOWKLeMTY8jHKm2FdexPALp3ilHmxdB5UGgLixJoQw9uPool2jdedrTih4vEtOqg44afp4t0V8D1meIAZvIzGzVnyVuziYeKY1KFzE2LtOtPteLh49wO6iFi7qguItZvAq2C_AwAA__9cbhXb">