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

    <tr>
        <th>Summary</th>
        <td>
            aarch64 globalisel crash compiling "atomicrmw add i128"
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          efriedma-quic
      </td>
    </tr>
</table>

<pre>
    Testcase (compile with "llc -mtriple=aarch64 -global-isel=1"):

```
@var = global i128 0
define void @fetch_and_add(i128* %p, i128 %bits) {
  %val = atomicrmw add i128* %p, i128 %bits seq_cst
  store i128 %val, i128* @var, align 16
  ret void
}
```

Gives:

LLVM ERROR: cannot select: %31:gpr64(s64), %34:gpr(s32) = G_UADDE %5:gpr, %3:gpr, %35:gpr (in function: fetch_and_add)

Godbolt: https://godbolt.org/z/8WGq495d1

There's some interaction with optimizations here; it works fine with -O0.

CC @aemerson @ornata 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8U8GO4ygQ_ZryBSXChR3HBx_c7UlfZjVSa3b32MJQidnBJg0krZ2vX4GTnZlWa6SImFdVr3hQT4ZgTgtRB_UD1EMhL3FyvqOjN6RnuXm9GFWMTv_bfaUQlQzEAPfKzWdjib2ZODFAtFaxzRy9OVsCMUjp1bSr2OZk3SjtxgSyIIYSEAFbED3wAfh93fHbb91W_Co9AzGwtZqZEvfsFtV0NAuxqzOaQcWPFNX0Ihf9IrUG3KdUwJ4B1mfAx7UUsB5NDIAtg-Zh5WEJvUqb-8joZqP8_Mak1ux3HCzQ64sK8U4SovP0f8ZV2ntBJshKEiKtOS2s3N3LPMUs4aa4GT6-ibw-mSuFd1f2-fNff7BPz89fnkH0TMllcZEFsqRiAgBrUYLoT2e_qwD3Ia1tOkiKVGsk4QLzpYiBPb382Q_Dp5RQ3-Nr-q-7WzDNgFnY8bKoaNySmr57ivYXDU6PzuazTTGesxw8AB5Oa2Dr_Anw8B3wsP_76bVqa13-XP91Ik-ATWDBzcTMEsnL3HmdQHeOZjbfZUICy8nigZnI3pz_FlgemZy4-cK3PxM_PqZXkjSTD25J384vMkpW6E7oVrSyoK7cNbwWTY11MXV8LI-6akirhh93paC92o1tOTYaW1WOVWE65Igl8n1e-VaqphE7WVPbaM5RQcVplsZurb3OSXlhQrhQV7cVbworR7IhuxFxlOobLRpE3_fZUdlAj4C4WiP76g4lOhC98jJMCayHwncJ3IyXU4CKWxNi-NE1mmipu1v1ByHLDGy1uFlOyd8fOQSLi7fdu_c0cbqMW-VmwEM-0Pq3OXv3T5pOPGSxAfCQ9f4XAAD__7cFUSE">