On Mon, Nov 15, 2021 at 9:01 AM Jakub Jelinek <ja...@redhat.com> wrote: > > On Fri, Nov 12, 2021 at 04:34:27PM +0100, Jakub Jelinek via Gcc-patches wrote: > > Why? When one uses 16-bit atomics, no matter what he does there will be > > some HImode math (at least the atomic instruction). And the rest can be > > dealt with. > > > > I have following patch queued for testing for this... > > Bootstrapped/regtested successfully on x86_64-linux and i686-linux, > ok for trunk? > > > 2021-11-12 Jakub Jelinek <ja...@redhat.com> > > > > PR target/103205 > > * config/i386/sync.md (atomic_bit_test_and_set<mode>, > > atomic_bit_test_and_complement<mode>, > > atomic_bit_test_and_reset<mode>): Use OPTAB_WIDEN instead of > > OPTAB_DIRECT. > > > > * gcc.target/i386/pr103205.c: New test.
OK. Thanks, Uros. > > > > --- gcc/config/i386/sync.md.jj 2021-10-04 19:53:01.025005548 +0200 > > +++ gcc/config/i386/sync.md 2021-11-12 15:27:47.387273428 +0100 > > @@ -726,7 +726,7 @@ (define_expand "atomic_bit_test_and_set< > > rtx result = convert_modes (<MODE>mode, QImode, tem, 1); > > if (operands[4] == const0_rtx) > > result = expand_simple_binop (<MODE>mode, ASHIFT, result, > > - operands[2], operands[0], 0, OPTAB_DIRECT); > > + operands[2], operands[0], 0, OPTAB_WIDEN); > > if (result != operands[0]) > > emit_move_insn (operands[0], result); > > DONE; > > @@ -763,7 +763,7 @@ (define_expand "atomic_bit_test_and_comp > > rtx result = convert_modes (<MODE>mode, QImode, tem, 1); > > if (operands[4] == const0_rtx) > > result = expand_simple_binop (<MODE>mode, ASHIFT, result, > > - operands[2], operands[0], 0, OPTAB_DIRECT); > > + operands[2], operands[0], 0, OPTAB_WIDEN); > > if (result != operands[0]) > > emit_move_insn (operands[0], result); > > DONE; > > @@ -801,7 +801,7 @@ (define_expand "atomic_bit_test_and_rese > > rtx result = convert_modes (<MODE>mode, QImode, tem, 1); > > if (operands[4] == const0_rtx) > > result = expand_simple_binop (<MODE>mode, ASHIFT, result, > > - operands[2], operands[0], 0, OPTAB_DIRECT); > > + operands[2], operands[0], 0, OPTAB_WIDEN); > > if (result != operands[0]) > > emit_move_insn (operands[0], result); > > DONE; > > --- gcc/testsuite/gcc.target/i386/pr103205.c.jj 2021-11-12 > > 15:47:21.218380790 +0100 > > +++ gcc/testsuite/gcc.target/i386/pr103205.c 2021-11-12 15:46:39.546980182 > > +0100 > > @@ -0,0 +1,11 @@ > > +/* PR target/103205 */ > > +/* { dg-do compile } */ > > +/* { dg-options "-O2 -mtune-ctrl=^himode_math" } */ > > + > > +unsigned short a; > > + > > +unsigned short > > +foo (void) > > +{ > > + return __sync_fetch_and_and (&a, ~1) & 1; > > +} > > Jakub >