Re: [PATCH] x86/cpu: Use prefetcht0 for prefetch() on 64-bit
From: Nick Desaulniers
Date: Wed Nov 04 2026 - 12:22:49 EST
On Tue, Nov 3, 2026 at 10:49 PM Martin Leitner-Ankerl
<martin.ankerl@xxxxxxxxx> wrote:
>
> > Thanks for the patch!
> > Is there a reason to have the cast vs simply use "r" constraint and
> > deref in the inline asm?
> > asm("prefetcht0 (%0)" : : "r" (x));
> > https://godbolt.org/z/xezh15oMe
>
> I mostly did it to be consistent with the 32-bit prefetch() and prefetchw()
> in the same file, but it also has a codegen benefit. With "m" the compiler
> can put an offset or index in the prefetcht0 itself, while with "r" it needs
> to compute the address into a register first:
> https://godbolt.org/z/j311eYzsY
Interesting! I learn more about inline asm everyday...
>
> Thanks for the ack!
> Martin
--
Thanks,
~Nick Desaulniers