<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/85779>85779</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[DAG] Match fixed width ISD::AVGFLOORS + ISD::AVGCEILS patterns
</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>
Followup to #84749 and #84753
We can match the signed AVG variants in a similar way:
```ll
define i4 @src_avgfloors(i4 %a0, i4 %a1) {
%and = and i4 %a0, %a1
%xor = xor i4 %a0, %a1
%srl = ashr i4 %xor, 1
%res = add i4 %and, %srl
ret i4 %res
}
define i4 @src_avgceils(i4 %a0, i4 %a1) {
%or = or i4 %a0, %a1
%xor = xor i4 %a0, %a1
%srl = ashr i4 %xor, 1
%res = sub i4 %or, %srl
ret i4 %res
}
```
Alive2: https://alive2.llvm.org/ce/z/L4yGAx
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0k0tvqzoQxz_NsBk1MgMUWLCg5RJVt1eVGql3eWRsJ_jIwZFt0vR8-iMefS3Oa3GkKMYzv3n8Rx7uvT4MSlWQ3UDWRHwMvXXV4787fbRD1Fn5UrXWGPs8njBYBEqKNE9L5INcL1kCrAFWL___KxR8wCMPosfQK5zzS6yftnjmTvMheNQDcvT6qA13-MxfIFmj4ZotP2MWg1R7PSjUKULKvBNf-PmwN9Y6D1RMVso4A7rF9TsGKhEhv1nCcTZOrSbN3PLHkIV_5y7Wzdx0_ozzziz5fP8KXqybyI-UU36h5FvVQa7pvDOvpFNhdTvl1yHkzY_FC6XNH2hfJf1C0d9R7sduhRbm94W_PYPlWht9VgRJjX0IJz-9FmqBWj7bN8acjxvrDkCtUEDtN6D2Pn3Z1pdIVoksk5JHqorzmBVpmeYU9RUJIdReJB1jLI8p4ZngjBdFUipGhSoiXRGjlCVxGcdZntEmlmIfl0XWpWWelfIaUqaOXJu36pH2flRVkeV5GRneKePnpSI6WCtxr50PODNABHQLRFMoJPVOGSWCtkNTbydf1kSumnxX3XjwkDKjffDvhYIOZl7Yic8a_G_etb2-KInPWoYe73bNNKSkrp-27f3Dw-MOgW4-mW__ubvf4YmHoNzgo9GZ6vNwDzr0Y7cR9gjUzp0ux9XJ2a9KBKB2VuOB2ln09wAAAP__dewykg">