From patchwork Sat Feb 19 19:07:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 51242 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BFC48385840C for ; Sat, 19 Feb 2022 19:08:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BFC48385840C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1645297726; bh=89zw6kcwRehb6lVoGgzGcNveKEvo7WueKQt3a48Oiog=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=LCCif43fCCBGyUdIBKzB8YjizJpY6ipaDF5N2SX34bIiP3msjfMktT8G5Uts9YvjJ vkhkb0E1VOSdpd6RY+mXA88uhSZzc94fnGmByqw6PvbXeQD7jhQp5RHcY9HHpHgPrk znv8iJ+XQKASGtoFJXfdIUcjhFKbJHc9yyCg+hUQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id A9069385843A for ; Sat, 19 Feb 2022 19:07:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A9069385843A Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CF7E61F383 for ; Sat, 19 Feb 2022 19:07:36 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BC90E1332F for ; Sat, 19 Feb 2022 19:07:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iwbOLPg/EWLkGwAAMHmgww (envelope-from ) for ; Sat, 19 Feb 2022 19:07:36 +0000 Date: Sat, 19 Feb 2022 20:07:35 +0100 To: gcc-patches@gcc.gnu.org Subject: [committed][nvptx] Don't skip atomic insns in nvptx_reorg_uniform_simt Message-ID: <20220219190733.GA1502@delia.home> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom de Vries via Gcc-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi, In nvptx_reorg_uniform_simt we have a loop: ... for (insn = get_insns (); insn; insn = next) { next = NEXT_INSN (insn); if (!(CALL_P (insn) && nvptx_call_insn_is_syscall_p (insn)) && !(NONJUMP_INSN_P (insn) && GET_CODE (PATTERN (insn)) == PARALLEL && get_attr_atomic (insn))) continue; ... that intends to handle syscalls and atomic insns. However, this also silently skips the atomic insn nvptx_atomic_store, which has GET_CODE (PATTERN (insn)) == SET. This does not cause problems, because the nvptx_atomic_store actually maps onto a "st" insn, and therefore is not atomic and doesn't need to be handled by nvptx_reorg_uniform_simt. Fix this by: - explicitly setting nvptx_atomic_store's atomic attribute to false, - rewriting the skip condition to make sure all insn with atomic attribute are handled, and - asserting that all handled insns are PARALLEL. Tested on nvptx. Committed to trunk. Thanks, - Tom [nvptx] Don't skip atomic insns in nvptx_reorg_uniform_simt gcc/ChangeLog: 2022-02-19 Tom de Vries * config/nvptx/nvptx.cc (nvptx_reorg_uniform_simt): Handle all insns with atomic attribute. Assert that all handled insns are PARALLELs. * config/nvptx/nvptx.md (define_insn "nvptx_atomic_store"): Set atomic attribute to false. gcc/testsuite/ChangeLog: 2022-02-19 Tom de Vries * gcc.target/nvptx/uniform-simt-3.c: New test. --- gcc/config/nvptx/nvptx.cc | 20 ++++++++++++++++---- gcc/config/nvptx/nvptx.md | 2 +- gcc/testsuite/gcc.target/nvptx/uniform-simt-3.c | 4 ++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc index 4942f1100da..55fab3e84cb 100644 --- a/gcc/config/nvptx/nvptx.cc +++ b/gcc/config/nvptx/nvptx.cc @@ -3274,12 +3274,24 @@ nvptx_reorg_uniform_simt () for (insn = get_insns (); insn; insn = next) { next = NEXT_INSN (insn); - if (!(CALL_P (insn) && nvptx_call_insn_is_syscall_p (insn)) - && !(NONJUMP_INSN_P (insn) - && GET_CODE (PATTERN (insn)) == PARALLEL - && get_attr_atomic (insn))) + + /* Skip NOTE, USE, etc. */ + if (!INSN_P (insn) || recog_memoized (insn) == -1) continue; + + if (CALL_P (insn) && nvptx_call_insn_is_syscall_p (insn)) + { + /* Handle syscall. */ + } + else if (get_attr_atomic (insn)) + { + /* Handle atomic insn. */ + } + else + continue; + rtx pat = PATTERN (insn); + gcc_assert (GET_CODE (pat) == PARALLEL); rtx master = nvptx_get_unisimt_master (); bool shuffle_p = false; for (int i = 0; i < XVECLEN (pat, 0); i++) diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md index 4c378ec6ecb..132ef2f1d34 100644 --- a/gcc/config/nvptx/nvptx.md +++ b/gcc/config/nvptx/nvptx.md @@ -2097,7 +2097,7 @@ (define_insn "nvptx_atomic_store" = "%.\tst%A0.b%T0\t%0, %1;"; return nvptx_output_atomic_insn (t, operands, 0, 2); } - [(set_attr "atomic" "true")]) + [(set_attr "atomic" "false")]) ;; Note: st is not an atomic insn. (define_insn "atomic_fetch_add" [(set (match_operand:SDIM 1 "memory_operand" "+m") diff --git a/gcc/testsuite/gcc.target/nvptx/uniform-simt-3.c b/gcc/testsuite/gcc.target/nvptx/uniform-simt-3.c new file mode 100644 index 00000000000..532fa825161 --- /dev/null +++ b/gcc/testsuite/gcc.target/nvptx/uniform-simt-3.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -muniform-simt -misa=sm_75" } */ + +#include "atomic-store-2.c"