[PATCH] riscv: Fix alignment-ignorant memcpy implementation

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Mon Mar 4 18:35:35 GMT 2024



On 04/03/24 15: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.

And at least with GCC 13.1 I see no difference besides the
'.attribute unaligned_access, 1'.


More information about the Libc-alpha mailing list