<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57988>57988</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RISC-V] i128 shift on RV32 calls __ashldi3 with out-of-range shift
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Amanieu
</td>
</tr>
</table>
<pre>
LLVM IR:
```llvm
define i128 @shift_128(i32 %0) #0 {
%2 = zext i32 %0 to i128
%3 = shl i128 1, %2
ret i128 %3
}
attributes #0 = { minsize nounwind optsize }
```
This generates this call to `__ashldi3` at the start of the function. The value in `a2` passed to `__ashldi3` is out of range if the shift amount is less than 64. The documentation for `__ashldi3` explicitly says that the shift amount must be between 0 and 63 inclusive.
```
addi a2, a1, -64
li a0, 1
li a1, 0
call __ashldi3@plt
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx9U01v2zAM_TX2RUhgy1_xwYe2wYAC3aUrei1ki441yFJgUf369aPkpCmWYYASieTj4yMl91Z-dA8Pzz_Z_WNS3CTZPslukjpbl9av8-qSMCoDTOV8x5Iyc5Ma8YWMhO9UwVnCqyzhLe1FxpLmdk1iwU_BYs8-4R3ZGcnQRqZvqCKi3KTXEnnC72LyGbIAnooT9qSy2Z8O8V8gLqr3CO6kgvhICZuVceoTmLHevCkjmT1idFzyz-1-p3ualGMHMLCIQInBHITWQTtBX14EiZWqoDMTSHFgDsWCzI7RGL0ZUFmzZU9kvQrtaXompAoeco7COZD_YqNC1keeRZgDZa2EceRMzNQGBowGF2QJw-pyLSLt4GcwKEJdNtrlihrej1oNCvUHc-IjpuM1-ewdsh5o4RuAYdQgja0uSP-gvVOvsP0-qavxtUJKFTYeblHEu9zU5VdYx2AW3Plfzoi9EIWB03bpocyOGv9zayl0eV2XPM-zuk1lV8i2aEWK1DJ0SXX7eP_rbvOcVPv1Ma1t07Aen-lphmqOfRVjbwqncBUbO27Wq4j41C-6mxCPLnww_AetAyF9vx3sTEb8aNZtc1zsbxiQTOWcB0eHqml3u3TqQI51WTa7sm2KUfb0K5uxAiiLjPOdbFItetAuqCa9qeo4-bOW13ld5dlu2zQSqrpv27EY8kIMNBuYhdLbUHhrl0O6dFFD7w-Oglo5dJcgPT91MABnfuFxskt3MwujwKdRbhe1_gGp-jcx">