<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/110454>110454</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
RISC-V: enable `-mno-strict-align` when `Zicclsm` is enabled
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
newpavlov
</td>
</tr>
</table>
<pre>
Otherwise LLVM generates terrible code for misaligned loads/stores, as can be seen here: https://rust.godbolt.org/z/ax1bqeeKx
The RVA22 specification states the following
>Even though mandated, misaligned loads and stores might execute extremely slowly. Standard software distributions should assume their existence only for correctness, not for performance.
This footnote is not present in the RVA23 spec, but it's unclear whether it got deprecated or implicitly inherited from RVA22.
In practice, most hardware which declares `Zicclsm` support has "fast" misaligned support implemented in hardware.
As another data point, it looks like Linux also considers that enabled `Zicclsm` means "fast" misaligned operations. From [this patch](https://lwn.net/ml/all/20240613191616.2101821-1-jesse@rivosinc.com/):
>If Zicclsm is present, the kernel will set both scalar and vector unaligned access speed to FAST.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0lM1u4zYQx5-GvgwsSJQ_ooMO3s0aCJqiwGaRQ28UOba4oTgqZ2Q5ffqCitM2AfYiAzI5-v0_SMPszxGxVdsvanu_MpP0lNqI82gugS6rjtxr-4f0mGbPCI-Pz7_DGSMmI8ggmJLvAoIlh3CiBINnE_JIB4GMY6WPLJSQlf4KhsGaCB0CI0boMaGqD9CLjKzqg9JHpY9pYinO5DoKUlA6K338W-mjuVbdX4i_XVV5r8rD2_NHj_D9-aA18IjWn7w14ikCyxten6FCoNnH821f_e3bBSNIT9O5h8FEZwRdpvuMDiY6eIOHwZ97AbyinQQBr5JwwPAKHGgOrwU8SR6UHDCdZDYJwXmW5Lsp8zBwT1NwYJinATOXT4BXz4LRIlAMr4t7llJCKxF58SuSLK9HTCdKg4kWi4_yPcOJSCIJg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