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

    <tr>
        <th>Summary</th>
        <td>
            [DAG] SimplifyDemandedVectorElts - add ISD::AVGCEILS/AVGCEILU/AVGFLOORS/AVGFLOORU nodes
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            good first issue,
            llvm:SelectionDAG
      </td>
    </tr>

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

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

<pre>
    https://rust.godbolt.org/z/e41G5d4q8

As we broadcasting the lowest element in `%r0`, the `%s0` shuffle before the avg nodes issuperfluous 
```ll
define <8 x i16> @shadd_demandedelts(<8 x i16> %a0, <8 x i16> %a1) {
  %s0 = shufflevector <8 x i16> %a0, <8 x i16> undef, <8 x i32> zeroinitializer
  %op = call <8 x i16> @llvm.aarch64.neon.shadd.v8i16(<8 x i16> %s0, <8 x i16> %a1)
  %r0 = shufflevector <8 x i16> %op, <8 x i16> undef, <8 x i32> zeroinitializer
 ret <8 x i16> %r0
}
define <8 x i16> @srhadd_demandedelts(<8 x i16> %a0, <8 x i16> %a1) {
  %s0 = shufflevector <8 x i16> %a0, <8 x i16> undef, <8 x i32> zeroinitializer
  %op = call <8 x i16> @llvm.aarch64.neon.srhadd.v8i16(<8 x i16> %s0, <8 x i16> %a1)
  %r0 = shufflevector <8 x i16> %op, <8 x i16> undef, <8 x i32> zeroinitializer
 ret <8 x i16> %r0
}

define <8 x i16> @uhadd_demandedelts(<8 x i16> %a0, <8 x i16> %a1) {
  %s0 = shufflevector <8 x i16> %a0, <8 x i16> undef, <8 x i32> zeroinitializer
  %op = call <8 x i16> @llvm.aarch64.neon.uhadd.v8i16(<8 x i16> %s0, <8 x i16> %a1)
  %r0 = shufflevector <8 x i16> %op, <8 x i16> undef, <8 x i32> zeroinitializer
 ret <8 x i16> %r0
}
define <8 x i16> @urhadd_demandedelts(<8 x i16> %a0, <8 x i16> %a1) {
  %s0 = shufflevector <8 x i16> %a0, <8 x i16> undef, <8 x i32> zeroinitializer
  %op = call <8 x i16> @llvm.aarch64.neon.urhadd.v8i16(<8 x i16> %s0, <8 x i16> %a1)
  %r0 = shufflevector <8 x i16> %op, <8 x i16> undef, <8 x i32> zeroinitializer
 ret <8 x i16> %r0
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkVlFvrCgY_TX4QmoQwdEHH6ZjbZpt0qST9nWD8qlsUGYBp9v--o04zZ20vb03uW9tMhnI4YPD4Ug4wjnVTwAl4peIV5GY_WBsef_XXo1mihojn8vB-4ND6RbRGtHazs7HvZGN0T42tke0fkG0BpZcc8n-zRGpENmu_1uHnwA31gjZCufV1GM_ANbmCZzHoGGEyWM1YZQRRLklod2FohVyC4TdMHedBtxAZyyEYXHs8WQkOKycmw9gOz2b2eETfUbWn9YrIKFTE2CU7nL8H1ZJhtIrjBhxg5DybwmjmCRI0N4hmr-polyEXb2HE0QLjDaXKwfGYcMYpdXrjo_QemM_mPnBgvMkoTuHU7rAL2CNmpRXQqsXsGdU5hCoWqH1e2FaH8dYCNsOGYsnMFMcpMbHfKn5QKP7ROMZqf0tfebwh_os-PerWnJyd1P9wlX7jWy1X8_Xz92dv4-589fz9qeufqM7O3_FO_v65EayTGWRFiKCMtkkJMkKTkk0lDkjrG2kyApKaCrynHdNwhlpRcGKLueRKimhjKRJknDCEx5DxtmGsIRlQAqaSMQIjELpOBypsX20PP5Q5myT5ZEWDWgXkgylvTESd8o6HwICIEoR3SFKl6ko3e5BQ-uVmart9TLGq8iWy9hFM_ducU05734QeeV1SElLPa_wXo0Hrbrn6vS9PobTv9Le4QsspMQ3-2rJTOl2-3i9u7q53SNan7oPa7e-vbu735_1H9ZEE81WvwldvfLD3MStGRGtg4K1uThY8w-0HtE6qHSI1uEw_g8AAP__yrq6bg">