Re: [PATCH] arm64/io: add constant-argument check
From: Arnd Bergmann
Date: Wed May 29 2024 - 12:16:32 EST
On Wed, May 29, 2024, at 17:08, Mark Rutland wrote:
> On Wed, May 29, 2024 at 02:29:37PM +0200, Arnd Bergmann wrote:
>> On Wed, May 29, 2024, at 13:14, Mark Rutland wrote:
>>
>> Yes, your version addresses both failures I ran into, and
>> I think all other theoretical cases.
>>
>> I would prefer to combine both though, using __always_inline
>> to force the compiler to pick the inline version over
>> __iowrite32_copy_full() even when it is optimizing for size
>> and it decides the inline version is larger, but removing
>> the extra complexity from the macro.
>
> Sorry, I'm not sure what you mean here. I don't see anything handling
> optimizing for size today so I'm not sure what change your suggesting to
> force the use of the inline version; AFAICT that'd always be forced for
> a suitable constant size.
>
> What change are you suggesting?
What I meant is that reason gcc chooses to not inline
the macro is when we build with CONFIG_CC_OPTIMIZE_FOR_SIZE.
Since it doesn't know that __const_memcpy_toio_aligned64()
is intended to be small after inlining, it sometimes
decides against it, which (with just my patch) would
fall back to the out-of-line __iowrite32_copy_full()
while trying to generate smaller code.
The __always_inline annotation just overrides the
calculation.
Arnd