https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104364

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vr...@gcc.gnu.org>:

https://gcc.gnu.org/g:04b54cc486cc6fcc40380445e500eaf46d7901dc

commit r12-7092-g04b54cc486cc6fcc40380445e500eaf46d7901dc
Author: Tom de Vries <tdevr...@suse.de>
Date:   Thu Feb 3 14:00:02 2022 +0100

    [nvptx] Fix .local atomic regressions

    In PR target/104364, two problems were reported:
    - in muniform-simt mode, an atom.cas insn is no longer executed in the
      "master lane" only.
    - in msoft-stack mode, an __atomic_compare_exchange_n on stack memory is
      translated assuming it accesses local memory, while that's not the case.

    Fix these by:
    - ensuring that all insns with atomic attribute are also predicable, such
      that the validate_change in nvptx_reorg_uniform_simt will succeed, and
      asserting that it does, and
    - guarding the local atomics implementation with a new function
      nvptx_mem_local_p that correctly handles msoft-stack.

    Tested on x86_64 with nvptx accelerator.

    gcc/ChangeLog:

    2022-02-04  Tom de Vries  <tdevr...@suse.de>

            PR target/104364
            * config/nvptx/nvptx-protos.h (nvptx_mem_local_p): Declare.
            * config/nvptx/nvptx.cc (nvptx_reorg_uniform_simt): Assert that
            change is validated.
            (nvptx_mem_local_p): New function.
            * config/nvptx/nvptx.md: Use nvptx_mem_local_p.
            (define_c_enum "unspecv"): Add UNSPECV_CAS_LOCAL.
            (define_insn "atomic_compare_and_swap<mode>_1_local"): New
            non-atomic, non-predicable define_insn, factored out of ...
            (define_insn "atomic_compare_and_swap<mode>_1"): ... here.
            Make predicable again.
            (define_expand "atomic_compare_and_swap<mode>"): Use
            atomic_compare_and_swap<mode>_1_local.

    gcc/testsuite/ChangeLog:

    2022-02-04  Tom de Vries  <tdevr...@suse.de>

            PR target/104364
            * gcc.target/nvptx/softstack-2.c: New test.
            * gcc.target/nvptx/uniform-simt-1.c: New test.

Reply via email to