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

    <tr>
        <th>Summary</th>
        <td>
            [AArch64][GlobalISel] HADD operations and combines
        </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>
    SDAG, via these nodes can pattern-recognise and optimise hadd and rhadd nodes. We should add the same operations for global isel.
```
  /// AVGFLOORS/AVGFLOORU - Averaging add - Add two integers using an integer of
 /// type i[N+1], halving the result by shifting it one bit right.
  /// shr(add(ext(X), ext(Y)), 1)
  AVGFLOORS,
  AVGFLOORU,
  /// AVGCEILS/AVGCEILU - Rounding averaging add - Add two integers using an
  /// integer of type i[N+2], add 1 and halve the result by shifting it one bit
 /// right. shr(add(ext(X), ext(Y), 1), 1)
  AVGCEILS,
 AVGCEILU,
```

There are tests in, for example, llvm/test/CodeGen/AArch64/hadd-combine.ll.
https://godbolt.org/z/xGs95MGz5
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMlF9v8yYUxj8NvjmKZbCdOBe-cOI5e6V3q9Su-3OJzanNRiACnLX99BPEWZvcvJWQwjmEB54f55g7J0eNWJNyR8o24bOfjK0FP-NxtIg66Y14q5_a5kDYHs6Sg5_QIWgj0MHANZy492j1yuJgRi0dAtcCzMnLYwgmLkTM2DiL-1L4A8FNZlYCQtJPCI4fEcwJLffSaAcvxsKoTM8VSIcqJVlD1tkysgaAsO4yoPn90H1_eHh8Iqy7zp9hBc0ZLR-lHuMhK2jCUf8akNrjiNbB7OKivmbAvATpD2X_dkKQpNz9StiOkrINECauzmFfuLVFNysP_Ru4Sb74kJYejEbopQcrx8mnd7d1kyWs4kIQVuGrJ6z6k7BtEL5Ef8UoJmj4Dbs_OdzfJJ6viRsa-5--fV9ghGlg8WhmLaLbr0K5k_1AdEuFLVSCGo0PHfjgj-nckr6g-iKchcwdocV15HF1fgk_Fw7Jmt8mtAjcInh03oHUQSoUHL7y40lhCJU6Hwnrwj8I6_ZG4AF1YNrYYVoXhHWhnleDOfZSY6pihU7enxzJm4up0YjeKJ8aOxLWvRPWvR7ctvzl8F4mos7FNt_yBGu6yVlVMZZtkqmmHHPOS1pUm6xgmx6xWK8rSmmBQ4mcJ7JmGSsoZVvKaJat0yHPaCUQK7pZFwMvSZHhkUuVBgfh7EQ6N2NNaZVVeaJ4j8rFfmes58M_qAXJm_9tsYCMsWg_by4dGBowrJRtYuuwsurn0ZEiU9J593GQl17FT8lVrWxJuTtEjW9PqEjZws9N237u81AxC0SXzFbVdwyln-Y-HUx4jOVN4g1O1vyNQ3ibaM8R1i0OzzX7LwAA__9g0nlv">