On Tue, May 5, 2026 at 9:54 AM Jakub Jelinek <[email protected]> wrote:
>
> Hi!
>
> With -ffuse-ops-with-volatile-access which is now even on by default
> thie splitter can split a 16 or 32-bit volatile memory test into
> an 8-bit volatile memory test, which is undesirable and e.g. when
> it refers to some memory mapped hw registers it could misbehave.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
> ok for trunk/16.2?
>
> 2026-05-05  Jakub Jelinek  <[email protected]>
>
>         PR target/125180
>         * config/i386/i386.md (HI/SI test -> QI test splitter): Punt if
>         operands[2] is a volatile MEM.
>
>         * gcc.target/i386/pr125180.c: New test.

OK for mainline and backports.

Thanks,
Uros.

>
> --- gcc/config/i386/i386.md.jj  2026-04-30 10:18:13.812688945 +0200
> +++ gcc/config/i386/i386.md     2026-05-04 17:40:00.188612108 +0200
> @@ -12772,6 +12772,7 @@ (define_split
>     "reload_completed
>      && GET_MODE (operands[2]) != QImode
>      && (!REG_P (operands[2]) || ANY_QI_REG_P (operands[2]))
> +    && !(MEM_P (operands[2]) && MEM_VOLATILE_P (operands[2]))
>      && ((ix86_match_ccmode (insn, CCZmode)
>          && !(INTVAL (operands[3]) & ~255))
>         || (ix86_match_ccmode (insn, CCNOmode)
> --- gcc/testsuite/gcc.target/i386/pr125180.c.jj 2026-05-04 17:47:37.651134771 
> +0200
> +++ gcc/testsuite/gcc.target/i386/pr125180.c    2026-05-04 17:47:19.826426119 
> +0200
> @@ -0,0 +1,14 @@
> +/* PR target/125180 */
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -masm=att" } */
> +/* { dg-final { scan-assembler "\ttestl\t\\\$1, \\\(" } } */
> +/* { dg-final { scan-assembler-not "\ttestb\t\\\$1, \\\(" } } */
> +
> +void foo (void);
> +
> +void
> +bar (unsigned volatile *x)
> +{
> +  if (*x & 1)
> +    foo ();
> +}
>
>         Jakub
>

Reply via email to