<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/56392>56392</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Address materialization via offset from prior constant
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:RISC-V,
performance
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
preames
</td>
</tr>
</table>
<pre>
Noticed while digging through SPEC that we have lots of sequences of the following variety:
```
1b912: 97 39 1d 00 auipc s3, 467
1b916: 93 89 69 90 addi s3, s3, -1786
1b91a: 17 3a 1d 00 auipc s4, 467
1b91e: 13 0a 4a 90 addi s4, s4, -1788
1b922: 97 3a 1d 00 auipc s5, 467
1b926: 93 8a 9a 8f addi s5, s5, -1799
1b92a: 17 3b 1d 00 auipc s6, 467
1b92e: 13 0b cb 8f addi s6, s6, -1796
1b932: 97 3b 1d 00 auipc s7, 467
1b936: 93 8b db 8f addi s7, s7, -1795
```
All but the first address in this sequence can be generated using a simple offset from the prior instruction. Since the addresses are PC relative, the offsets require a bit of care to compute generically via address expressions.
Since the offset instructions are likely to be compressible, the code size for the sequence drops from 8 bytes per address to 2 bytes per address for everything except the initial address.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxtVE1vozAQ_TXhMmpEoIRw4JBNd6W9rKqttHd_DOCtg6lt0qa_fscmZZMWCY3x2G_evJkBbuS5_mW8EijhtVMaQaq2VX0LvrNmbDt4evx-oA3z8IrQsROCNt6BacDhy4i9wLjxHUJjtDavAXxiVqE_r_L9Kn1YpfvVNr08cQsAG15tMjqHqoS8go2ENCU3G9UgaHX5KjvA_ba8AWwjIIddBdsKqgiQUsEMmOzdptxtb4AsADfExL4y3S8xYQTkkDK4Z5-YImCygWl3DcxmTQtMxQJTNmsiGga75popAiZLTFV1A5w18a9M2yWmWRMHwT8xRcBkA9NN9fJZ0wJTucCUz5o4yM9METDZwFQsDshea-Cjn6ZKWecD3qJzoHpyKjcPHwjWA0dosUfLPI3x6MIEMnDqONA8m6Zx6KGx5hjDDVYZS2Gct6PwyvRrgCcVIoXTCw3NNLMIjwewqJlXJwz5hgtTOEf-l1HRFQZc-fABiADwBoQ5DqO_JKQE0_oMJ8VmAfg2hJWI3fqiPdr_OVwyvkpxykarZ6RgxEF6A02Mw_WcmzASSfZ7-BJt9MxVktYMbirCDvjZk8AB7ZwUxcwW3CEMntCeqeRUU3wTOExNUb3yiumPm1TDay2JrHNZ5RVLvPIa6_0l3pEaZAmm3lmQFety3Z-pN4IEe9b7ZLS67rwfXPiPZD_oaZXvRr4m8bTR-vSx3A3W_EXhaaucG9HRS7HNqyzp6lxsMC1LLLGQEtNt0aDI0mqXM8S8yZtEM47a1avi2yrLOBPP2Eti_P3z6XD3h1yhvLRQYageR0blDM7iIVF1lmZZWqbFZpdtsmrNZVFyKZuU83wnimx1n-KRKb0OOa6NbRNbx3T52Do61Mp59_-QUTvbHjGmQvHZ6Dtja-ozO6JLorI6yvoHJAa41A">