From patchwork Sat Jul 20 17:19:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Segher Boessenkool X-Patchwork-Id: 1134413 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-505371-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="i+4njjui"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45rZPB0DzKz9s7T for ; Sun, 21 Jul 2019 03:19:41 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; q=dns; s=default; b=osZwesqdl1NDcdHe+Rr gUvuuHeE18AB2bKWVlvQ7MWdWqv1yffnW4Jg41fUQvPq4+t+mvxc3HCo+i2X2jt1 RPqmIgcY/2eWcR4jYYMezQlOOHcB90PzLzZEHhhPa7uBwz2Al+nupnPMJ95LOCzZ yiaePUqYpAzWb5AYjnGPyURA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; s=default; bh=t7DRvwIOX5RD9BSQ1uTlRVGhQ kw=; b=i+4njjui8UZoISw1/vDK/sU6syXs2uuHSGYsA6aqaSd4tGZoCW5BRFils TJQBYDbUOy9to9R13p6cw5Wei41764NCaMe8EsAB82ZXqTTnT2fh/lKg42K1wPjl 4MwtIc5gRlPK1lbdqgarvzm3Rgq5++kwKCx7Eak/sDPslv5gtA= Received: (qmail 3299 invoked by alias); 20 Jul 2019 17:19:33 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 3232 invoked by uid 89); 20 Jul 2019 17:19:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=xexp, XEXP, modernize X-HELO: gcc1-power7.osuosl.org Received: from gcc1-power7.osuosl.org (HELO gcc1-power7.osuosl.org) (140.211.15.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 20 Jul 2019 17:19:31 +0000 Received: by gcc1-power7.osuosl.org (Postfix, from userid 10019) id E66AE12407FD; Sat, 20 Jul 2019 17:19:29 +0000 (UTC) From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: dje.gcc@gmail.com, Segher Boessenkool Subject: [PATCH 1/4] rs6000: New predicate any_memory_operand Date: Sat, 20 Jul 2019 17:19:14 +0000 Message-Id: <621412b11d6364b6b62b6525d14e8ba4a8b409a1.1563642475.git.segher@kernel.crashing.org> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes The new predicate accepts both memory_operand and volatile_mem_operand. 2019-07-20 Segher Boessenkool * config/rs6000/predicates.md (volatile_mem_operand): Modernize syntax. (any_memory_operand): New predicate. (reg_or_mem_operand): Use it. --- gcc/config/rs6000/predicates.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md index 5f687ea..13c7c02 100644 --- a/gcc/config/rs6000/predicates.md +++ b/gcc/config/rs6000/predicates.md @@ -703,12 +703,17 @@ (define_predicate "zero_fp_constant" ;; memory references. So this function allows us to recognize volatile ;; references where it's safe. (define_predicate "volatile_mem_operand" - (and (and (match_code "mem") - (match_test "MEM_VOLATILE_P (op)")) + (and (match_code "mem") + (match_test "MEM_VOLATILE_P (op)") (if_then_else (match_test "reload_completed") (match_operand 0 "memory_operand") (match_test "memory_address_p (mode, XEXP (op, 0))")))) +;; Return 1 if the operand is a volatile or non-volatile memory operand. +(define_predicate "any_memory_operand" + (ior (match_operand 0 "memory_operand") + (match_operand 0 "volatile_mem_operand"))) + ;; Return 1 if the operand is an offsettable memory operand. (define_predicate "offsettable_mem_operand" (and (match_operand 0 "memory_operand") @@ -891,11 +896,10 @@ (define_predicate "scc_eq_operand" ;; Return 1 if the operand is a general non-special register or memory operand. (define_predicate "reg_or_mem_operand" - (ior (match_operand 0 "memory_operand") + (ior (match_operand 0 "gpc_reg_operand") + (match_operand 0 "any_memory_operand") (and (match_code "mem") - (match_test "macho_lo_sum_memory_operand (op, mode)")) - (match_operand 0 "volatile_mem_operand") - (match_operand 0 "gpc_reg_operand"))) + (match_test "macho_lo_sum_memory_operand (op, mode)")))) ;; Return 1 if the operand is CONST_DOUBLE 0, register or memory operand. (define_predicate "zero_reg_mem_operand" From patchwork Sat Jul 20 17:19:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Segher Boessenkool X-Patchwork-Id: 1134414 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-505372-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="NCV8Kcy6"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45rZPQ3C4Lz9s7T for ; Sun, 21 Jul 2019 03:19:54 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; q=dns; s=default; b=Fx5fKOynch11kJ/YHo8 5cMaYKsO3HShwIEc8kGIL5S3cnl7cEa/wD/T2Znc8fbvrijd6izHm2CmH/1ERtRf qyMlWqXbBUz/XtgReiKNpiG5FZefXKiYd9lB3CwjFUMr52MDFDpOcilsrqeRFmlN n/+IPFZOp47AHvISDt5BAems= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; s=default; bh=GOriLCAFAOAbnPOB8C80818F1 60=; b=NCV8Kcy60v79QVkKyGw2N5ufhCKCtRk2SfZgjh/jtLlZHYepUsLIXem6+ LH/6p7Np4g0uohR3THQ1rCjDFHubj449Xrt6HLpqGFy51D5RZCv8yo3Dje7CbEKN AaFePlTtz7Grvsd9/HBYS2dibGdXYMVWhCOQOs2Lgg2eDdtTTg= Received: (qmail 4331 invoked by alias); 20 Jul 2019 17:19:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 4276 invoked by uid 89); 20 Jul 2019 17:19:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1718 X-HELO: gcc1-power7.osuosl.org Received: from gcc1-power7.osuosl.org (HELO gcc1-power7.osuosl.org) (140.211.15.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 20 Jul 2019 17:19:39 +0000 Received: by gcc1-power7.osuosl.org (Postfix, from userid 10019) id E2EAC1240342; Sat, 20 Jul 2019 17:19:37 +0000 (UTC) From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: dje.gcc@gmail.com, Segher Boessenkool Subject: [PATCH 2/4] rs6000: Make lwa_operand use any_memory_operand Date: Sat, 20 Jul 2019 17:19:15 +0000 Message-Id: <8a7b2e68e0e51569b5779cc171cd1de39608b4fb.1563642475.git.segher@kernel.crashing.org> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes Testcase from comex, see https://lwn.net/Articles/793932/ . 2019-07-20 Segher Boessenkool * config/rs6000/predicates.md (lwa_operand): Allow volatile memory. gcc/testsuite/ * gcc.target/powerpc/volatile-mem.c: New testcase. --- gcc/config/rs6000/predicates.md | 2 +- gcc/testsuite/gcc.target/powerpc/volatile-mem.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/volatile-mem.c diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md index 13c7c02..23d626b 100644 --- a/gcc/config/rs6000/predicates.md +++ b/gcc/config/rs6000/predicates.md @@ -929,7 +929,7 @@ (define_predicate "lwa_operand" if (gpc_reg_operand (inner, mode)) return true; - if (!memory_operand (inner, mode)) + if (!any_memory_operand (inner, mode)) return false; addr = XEXP (inner, 0); diff --git a/gcc/testsuite/gcc.target/powerpc/volatile-mem.c b/gcc/testsuite/gcc.target/powerpc/volatile-mem.c new file mode 100644 index 0000000..c8a7444 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/volatile-mem.c @@ -0,0 +1,16 @@ +/* { dg-options "-O2 -std=c11" } */ +/* { dg-require-effective-target lp64 } */ + +/* This tests if the instructions used for C atomic are optimised properly + as atomic by the target code, too. */ + +#include + +int load(_Atomic int *ptr) +{ + return atomic_load_explicit(ptr, memory_order_relaxed); +} + +/* There should be only two machine instructions, an lwa and a blr: */ +/* { dg-final { scan-assembler-times {(?n)^\s+[a-z]} 2 } } */ +/* { dg-final { scan-assembler-times {\mlwa\M} 1 } } */ From patchwork Sat Jul 20 17:19:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Segher Boessenkool X-Patchwork-Id: 1134415 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-505373-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="hFKxXo7s"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45rZPd2Fnzz9s7T for ; Sun, 21 Jul 2019 03:20:05 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; q=dns; s=default; b=B+Rj6FjKJyjVVgDg12h C0ENGwrUTEm6tUL5uqAjdSdxwn6+E/k/F/RPxO590e3Cy4Xiij4JgUsfJIo8WBws F4uhhKSmtOF/CBUy5/c6Fce1FtKyuN+QIjzfGZ4ROr71A9LuIbl0K+uv5vc9q2Sc LALqi6Vu7iXZqZGAgth7Mnp8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; s=default; bh=etgIe+eznfNYKdf6BTV/TY9eJ 6Q=; b=hFKxXo7skFe6eLHm2z5MaWzhNYwveIlsnIr0bw02zXo2xm9CWR6B76mUZ c2Es19/79SjKMV6bUz3qO01YGoPBytj9G4jyhfWw8/lBj4n+66Zw5P2SDf14W7R5 d5wvXKwN5xlvtrGvo8ArXm4nAgu/Dd6M2HOYnXzDYbNMNMxq40= Received: (qmail 4899 invoked by alias); 20 Jul 2019 17:19:45 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 4791 invoked by uid 89); 20 Jul 2019 17:19:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=HX-Languages-Length:756 X-HELO: gcc1-power7.osuosl.org Received: from gcc1-power7.osuosl.org (HELO gcc1-power7.osuosl.org) (140.211.15.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 20 Jul 2019 17:19:43 +0000 Received: by gcc1-power7.osuosl.org (Postfix, from userid 10019) id 4629B12407FD; Sat, 20 Jul 2019 17:19:42 +0000 (UTC) From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: dje.gcc@gmail.com, Segher Boessenkool Subject: [PATCH 3/4] rs6000: Make input_operand use any_memory_operand Date: Sat, 20 Jul 2019 17:19:16 +0000 Message-Id: In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes 2019-07-20 Segher Boessenkool * config/rs6000/predicates.md (input_operand): Allow volatile memory. --- gcc/config/rs6000/predicates.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md index 23d626b..7c451df 100644 --- a/gcc/config/rs6000/predicates.md +++ b/gcc/config/rs6000/predicates.md @@ -1031,7 +1031,7 @@ (define_predicate "input_operand" const_double,const_wide_int,const_vector,const_int") { /* Memory is always valid. */ - if (memory_operand (op, mode)) + if (any_memory_operand (op, mode)) return 1; /* For floating-point, easy constants are valid. */ From patchwork Sat Jul 20 17:19:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Segher Boessenkool X-Patchwork-Id: 1134416 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-505374-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="xgzEqvJY"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45rZPr5nKzz9sBF for ; Sun, 21 Jul 2019 03:20:16 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; q=dns; s=default; b=A5Gupb+FIpWUJWhLnRZ xRN/UNl7dx/jAZC7FKIwD4bS8skkWeJPYGo68C/uXK944luDOxskHbs2wD8TIPBx bmnZbZwXb+lpKTGvB6mQKO79Y85xLckbx3rI91gwncRCxc1b/Q9MQKHTteWezDRL lU/Jnc+1oasNgXu5p+TBK7ro= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; s=default; bh=H5kA0TTUrBTX9ep5tbz/7jdN/ YI=; b=xgzEqvJYC6tFPCE3ZPg5mPu6Ii9KGvq0vcXZCt+PFLbm50KD5Neldu9Hz w7G8L6vu8CYfGgv/YGj+yLCwUbKl1/xoqWUVRAPnMR7MSJx1iEzFQaCOoOb4BrRx vPenJWXqo7QCNsIM7lWWAh6HFK9KXCJQS0qPbejVSSK6Kl3M2w= Received: (qmail 5354 invoked by alias); 20 Jul 2019 17:19:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 5288 invoked by uid 89); 20 Jul 2019 17:19:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=HX-Languages-Length:876 X-HELO: gcc1-power7.osuosl.org Received: from gcc1-power7.osuosl.org (HELO gcc1-power7.osuosl.org) (140.211.15.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 20 Jul 2019 17:19:47 +0000 Received: by gcc1-power7.osuosl.org (Postfix, from userid 10019) id 52AA812407FD; Sat, 20 Jul 2019 17:19:46 +0000 (UTC) From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: dje.gcc@gmail.com, Segher Boessenkool Subject: [PATCH 4/4] rs6000: Make offsettable_mem_operand use any_memory_operand Date: Sat, 20 Jul 2019 17:19:17 +0000 Message-Id: <8d3588c59f810b7ff95aedabcd4ec6e8e6e82b2d.1563642475.git.segher@kernel.crashing.org> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes 2019-07-20 Segher Boessenkool * config/rs6000/predicates.md (offsettable_mem_operand): Allow volatile memory. --- gcc/config/rs6000/predicates.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md index 7c451df..5a2d2d3 100644 --- a/gcc/config/rs6000/predicates.md +++ b/gcc/config/rs6000/predicates.md @@ -716,7 +716,7 @@ (define_predicate "any_memory_operand" ;; Return 1 if the operand is an offsettable memory operand. (define_predicate "offsettable_mem_operand" - (and (match_operand 0 "memory_operand") + (and (match_operand 0 "any_memory_operand") (match_test "offsettable_nonstrict_memref_p (op)"))) ;; Return 1 if the operand is a simple offsettable memory operand