<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/122688>122688</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
GlobalISel sdiv/sext shift right heavy
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:AMDGPU,
llvm:globalisel
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tpopp
</td>
</tr>
</table>
<pre>
[reduced.gisel.txt](https://github.com/user-attachments/files/18395905/reduced.gisel.txt)
[reduced.sdisel.txt](https://github.com/user-attachments/files/18395904/reduced.sdisel.txt)
[reduced.txt](https://github.com/user-attachments/files/18395903/reduced.txt)
Given input IR like:
```
%i78 = sdiv i32 %i, 128
%i80 = sext i32 %i78 to i64
%i83 = sdiv i64 %i80, 4
```
I see many more `ashr` and `lshr` instructions in the result with global-isel. I believe SDIsel is instead using `v_bfe` instead of some 2-4 SHR instructions.
I've been looking at this and reducing with the instruction `llc -O3 -march=amdgcn -mcpu=gfx942 -mtriple amdgcn-amd-hmcsa ./reduced.ll -global-isel={true,false}`
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyslMGOpDYQhp-muJRoQRkMHDj0DupJH6JEO8o5sqEAZwy0sOnMvH2Ee7JDNtKeVmrJsqvq_-pvu1DOmWFmriH_AnkTqc2Py1r723K7RXrp3vfAyt3WcncajGN78m8e8gaoHL2_ORBnoAvQZTB-3PSpXSagy-Z4jZX3qh0nnr0DuvTG8r6mpajyKsmBLv_XpQqS84Houp-IzA7Ig_D3zJ8DEwfYJyU5P5s7z2jm2-bx-hWteeUdEWIgk49fckYEyk1RIogGXWfuaASFM6AnTKn8llMmjxx-899yihL9gkZmn1nioCSzj8pdK_uODMn5io4ZJzW_47SsjCAT5cYVZIJq7vat_dia2fl1a71ZZodmRj8yruw26_Fv40cc7KKVjcOfjVfUbA3fGV-aq2OLxgUBVh1uzszDrnz_U_f8r_QeWXp0y8RIcYYvv3z9D_L00S9QcWfUzDPaZXndpZRHPxoXGg4XsR-GnvYeDyLBjm0x_k1gPKm1HUE0auqGdsZ4am8biGbo36qMMJ78am6W8RGO1dTF49Q6hXg63Le1iPHBOYgGii9-3RjoqVfWMRQNyCTqatFVolIR12khZCFlmchorIu8KKhKtK5KFlWfFSxLWeZ9J0mIVuvI1JRQnqSpSNNUkDzJQsted60oVJtp2UOW8KSMPVl7n07LOkTGuY3rlEiWZWSVZuvC0BNp1b7y3IE4n39tnn__A4iAnoBorwVxfjgJRoj2j8Ra75FYb4ODLLHGeffJ8cZbrp9DzfWFbXhyQJfwPt1oeo-rGUaPI6v7e7Sttv7BoIUWHkt8W5e_uPVAl-AlDNvDzr2mfwIAAP__owOAEg">