[PATCH] riscv: Fix alignment-ignorant memcpy implementation
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Mon Mar 4 19:07:39 GMT 2024
On 04/03/24 16:04, Vineet Gupta wrote:
>
>
> On 3/4/24 10:30, Adhemerval Zanella Netto wrote:
>>
>> On 04/03/24 15:28, Adhemerval Zanella Netto wrote:
>>>
>>> On 04/03/24 15:24, Andreas Schwab wrote:
>>>> On Mär 04 2024, Adhemerval Zanella wrote:
>>>>
>>>>> Also, there is no reason why the implementation can't be coded in C,
>>>>> since it uses only normal registers and the compiler is able to
>>>>> generate code as good as the assembly implementation. I have not
>>>>> checked the performance, but the C implementation uses the same
>>>>> strategies, the generate code with gcc 13 seems straightforward, and
>>>>> the tail code also avoid byte-operations.
>>>> RISC-V is a strict-alignment target, and there is a non-zero chance that
>>>> the C compiler messes this up.
>>>>
>>> I am aware, but there is other project that successfully provides C
>>> implementation (musl, for instance, where it optimizes for aligned
>>> access) so I think if this implementation does have any mistake this
>>> should not be considered a blocked for this change.
>> Maybe we should force -mno-strict-align for the unaligned implementation.
>
> That alone might not be sufficient. RISC-V gcc gates alignment with an
> additional cpu tune param and latter overrides the usual
> -m[no-]strict-align: meaning you could have more strict alignment but
> not any less. The default -mtune is rocket which penalizes unaligned access.
How does gcc optimization and strict-align plays with __may_alias__, it
would still tries to generated aligned access in this case?
More information about the Libc-alpha
mailing list