On Sun, Jun 21, 2026 at 2:38 PM Oleg Tolmatcev <[email protected]> wrote:
>
> Match Clang's declaration of _m_prefetchw to avoid requiring
> const_cast<void *> at call sites.
>
> gcc
>         * config/i386/prfchwintrin.h (_m_prefetchw): Take
>         volatile const void * instead of void *.

This now matches Clang and the real Windows header rather than just
MSVC's docs, but introduces a new warning with -Wcast-qual. Please
wrap the builtin in

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-qual"
  __builtin_prefetch (...)
#pragma GCC diagnostic pop

and add a testcase that checks that warning is not emitted with -Wcast-qual.

Also, do you have commit rights to the source repository?

Thanks,
Uros.

>
> Signed-off-by: oltolm <[email protected]>
> ---
>  gcc/config/i386/prfchwintrin.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/gcc/config/i386/prfchwintrin.h b/gcc/config/i386/prfchwintrin.h
> index af3bded18e0..2ac190964de 100644
> --- a/gcc/config/i386/prfchwintrin.h
> +++ b/gcc/config/i386/prfchwintrin.h
> @@ -29,9 +29,9 @@
>  #define _PRFCHWINTRIN_H_INCLUDED
>
>  extern __inline void __attribute__((__gnu_inline__, __always_inline__, 
> __artificial__))
> -_m_prefetchw (void *__P)
> +_m_prefetchw (volatile const void *__P)
>  {
> -  __builtin_prefetch (__P, 1, 3 /* _MM_HINT_T0 */);
> +  __builtin_prefetch ((const void *) __P, 1, 3 /* _MM_HINT_T0 */);
>  }
>
>  #endif /* _PRFCHWINTRIN_H_INCLUDED */
> --
> 2.54.0.windows.1
>

Reply via email to