From patchwork Tue Oct 2 16:19:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147986 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp5354749lji; Tue, 2 Oct 2018 09:20:15 -0700 (PDT) X-Google-Smtp-Source: ACcGV610Rd5Uy/qJ09FsRZO0FzA4VLS8NQ9sG1jUCVGbubYmsoLBd2bvvA6EPfE4R5EgKKG4sUCH X-Received: by 2002:a63:f005:: with SMTP id k5-v6mr15366669pgh.259.1538497215497; Tue, 02 Oct 2018 09:20:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538497215; cv=none; d=google.com; s=arc-20160816; b=ANgRTmdYdhiUcxGUDtMpi93lkg5DioGR4WvdkjSWwkeHjY4vC3Is3qq/KPMLF6DT70 5MwdTWCoj+c1VFrBVu7GwDDh6KlBmGgo39AUCihJPISbjkPWcSwUxfIqWmziW9EN7aqu tvOBz2fRrGWxtiXDPV1PzIeiEAIksIGaoXirrUHRHPnYUyJ56oXYJL8kRj4SKMwu030x neLv/pa3nRMBzGl+yQ0dQmYmZNU5m5/b74bDz/4RuUiAA5Fa3dSzSHXtA/VL7LxrJT1+ 1ceB2SLktjBdkQJ0H5IudDWKb/DFa/y5ztTtvPfazolA5bhaVZkOtWXueiTK7MvzeDnp 0LZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature; bh=aGTDQ/eunUfsLNv/8fKvAW8znwnqcmT6nDVY7wN2D5o=; b=MqIUYZgo1I6sKBUo95urdDCLIkbaACDG9LhPlQVq23syjbhVxwo4x8fUkrzDW42Eaz jjv8KvNnBsKigFZXsoKBcVS2kU39GAkiTbcEhLZH1stPCPKFDZM5OTioaR+PcpRXuSUk wT8pKhZHKe8JivLfixnFEVbuOVfe2uONI2NwEu5gVwf8CZ/xhFc1FMYcl6T1VV893EAU kNGjzR33ugIoktKkl90QCHWmOVBFS8+8pgBHqA0UbklYTsHDnX8TXgGt7MQGdzxjrkpc S+NmpOC3qzzZFchFlSAUP7Ijc+prr4EKIi7QP/xHZLxuzoHphAVT1IEO02Z0TnpwpAZq CwHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=XB8ryt28; dkim=pass header.i=@linaro.org header.s=google header.b="OCnAcCO/"; spf=pass (google.com: domain of gcc-patches-return-486818-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-486818-patch=linaro.org@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id e2-v6si17836629pfh.64.2018.10.02.09.20.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Oct 2018 09:20:15 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-486818-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=XB8ryt28; dkim=pass header.i=@linaro.org header.s=google header.b="OCnAcCO/"; spf=pass (google.com: domain of gcc-patches-return-486818-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-486818-patch=linaro.org@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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; q=dns; s= default; b=YVg+xIaHzeIWzE9ky7KE5LtTgRACS3FNGk9jvBPd4im5ew1gyfp3C viCsUWIKn4yPOlHqXK0wLKUrozYJxs2pOsC8jg7w5a2v8pblNlgSs9AmVjyTW609 mRq6ixaO8d7l6LyBmVqrwWZj3CFxuxM7bHiNJbOlTqEOvDikA4V7h0= 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; s= default; bh=/IwFuDwKIn6EDFybFNIQm6eTM0A=; b=XB8ryt28mRqXWt51vZE4 s5DGj6Oo4aKIcfxSmmEPnY5tJ82GbxvMM7eNI+SF/lCJnUNoFmpPKpb8fS5/DpE0 3cS2xRZBZwYc9TqjaX1nxu8ImY0R0aO7B/A/a13K+8ytDBVz6irBusHyHSEhTIXY Nxw5hmqQiplVefG0AlltKTQ= Received: (qmail 66704 invoked by alias); 2 Oct 2018 16:19:29 -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 66600 invoked by uid 89); 2 Oct 2018 16:19:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=PLUS, HX-Received:sk:11-v6mr X-HELO: mail-ot1-f47.google.com Received: from mail-ot1-f47.google.com (HELO mail-ot1-f47.google.com) (209.85.210.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 02 Oct 2018 16:19:26 +0000 Received: by mail-ot1-f47.google.com with SMTP id w67so2464164ota.7 for ; Tue, 02 Oct 2018 09:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aGTDQ/eunUfsLNv/8fKvAW8znwnqcmT6nDVY7wN2D5o=; b=OCnAcCO/x0jjG5slj5m0+S9NZ6iAVJZW7E+6Vx07BOPmQQ3fRzDS6ew8Eu2J9QT9a2 E7CSyfKzxcyXLoAYcPu59MFhzY+zxebh7hNHavM8BRvQN5Wb2L8ENRWGIrUXik5BN4HQ CERFEPkkcxR+lZk+4MT1YS8agwNbQsnZwyiqc= Return-Path: Received: from cloudburst.twiddle.net ([187.217.227.243]) by smtp.gmail.com with ESMTPSA id j15-v6sm145987oth.27.2018.10.02.09.19.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Oct 2018 09:19:23 -0700 (PDT) From: Richard Henderson To: gcc-patches@gcc.gnu.org Cc: ramana.radhakrishnan@arm.com, agraf@suse.de, marcus.shawcroft@arm.com, james.greenhalgh@arm.com, richard.earnshaw@arm.com Subject: [PATCH, AArch64 v2 03/11] aarch64: Improve swp generation Date: Tue, 2 Oct 2018 11:19:07 -0500 Message-Id: <20181002161915.18843-4-richard.henderson@linaro.org> In-Reply-To: <20181002161915.18843-1-richard.henderson@linaro.org> References: <20181002161915.18843-1-richard.henderson@linaro.org> Allow zero as an input; fix constraints; avoid unnecessary split. * config/aarch64/aarch64.c (aarch64_emit_atomic_swap): Remove. (aarch64_gen_atomic_ldop): Don't call it. * config/aarch64/atomics.md (atomic_exchange): Use aarch64_reg_or_zero. (aarch64_atomic_exchange): Likewise. (aarch64_atomic_exchange_lse): Remove split; remove & from operand 0; use aarch64_reg_or_zero for input; merge ... (@aarch64_atomic_swp): ... this and remove. --- gcc/config/aarch64/aarch64.c | 13 ---------- gcc/config/aarch64/atomics.md | 49 +++++++++++------------------------ 2 files changed, 15 insertions(+), 47 deletions(-) -- 2.17.1 diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 0e2b85de1e3..f7b0af2589e 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -14403,15 +14403,6 @@ aarch64_emit_bic (machine_mode mode, rtx dst, rtx s1, rtx s2, int shift) emit_insn (gen (dst, s2, shift_rtx, s1)); } -/* Emit an atomic swap. */ - -static void -aarch64_emit_atomic_swap (machine_mode mode, rtx dst, rtx value, - rtx mem, rtx model) -{ - emit_insn (gen_aarch64_atomic_swp (mode, dst, mem, value, model)); -} - /* Emit an atomic load+operate. CODE is the operation. OUT_DATA is the location to store the data read from memory. OUT_RESULT is the location to store the result of the operation. MEM is the memory location to read and @@ -14452,10 +14443,6 @@ aarch64_gen_atomic_ldop (enum rtx_code code, rtx out_data, rtx out_result, a SET then emit a swap instruction and finish. */ switch (code) { - case SET: - aarch64_emit_atomic_swap (mode, out_data, src, mem, model_rtx); - return; - case MINUS: /* Negate the value and treat it as a PLUS. */ { diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md index e44301b40c7..bc9e396dc96 100644 --- a/gcc/config/aarch64/atomics.md +++ b/gcc/config/aarch64/atomics.md @@ -136,7 +136,7 @@ (define_expand "atomic_exchange" [(match_operand:ALLI 0 "register_operand" "") (match_operand:ALLI 1 "aarch64_sync_memory_operand" "") - (match_operand:ALLI 2 "register_operand" "") + (match_operand:ALLI 2 "aarch64_reg_or_zero" "") (match_operand:SI 3 "const_int_operand" "")] "" { @@ -156,10 +156,10 @@ (define_insn_and_split "aarch64_atomic_exchange" [(set (match_operand:ALLI 0 "register_operand" "=&r") ;; output - (match_operand:ALLI 1 "aarch64_sync_memory_operand" "+Q")) ;; memory + (match_operand:ALLI 1 "aarch64_sync_memory_operand" "+Q")) ;; memory (set (match_dup 1) (unspec_volatile:ALLI - [(match_operand:ALLI 2 "register_operand" "r") ;; input + [(match_operand:ALLI 2 "aarch64_reg_or_zero" "rZ") ;; input (match_operand:SI 3 "const_int_operand" "")] ;; model UNSPECV_ATOMIC_EXCHG)) (clobber (reg:CC CC_REGNUM)) @@ -175,22 +175,25 @@ } ) -(define_insn_and_split "aarch64_atomic_exchange_lse" - [(set (match_operand:ALLI 0 "register_operand" "=&r") +(define_insn "aarch64_atomic_exchange_lse" + [(set (match_operand:ALLI 0 "register_operand" "=r") (match_operand:ALLI 1 "aarch64_sync_memory_operand" "+Q")) (set (match_dup 1) (unspec_volatile:ALLI - [(match_operand:ALLI 2 "register_operand" "r") + [(match_operand:ALLI 2 "aarch64_reg_or_zero" "rZ") (match_operand:SI 3 "const_int_operand" "")] UNSPECV_ATOMIC_EXCHG))] "TARGET_LSE" - "#" - "&& reload_completed" - [(const_int 0)] { - aarch64_gen_atomic_ldop (SET, operands[0], NULL, operands[1], - operands[2], operands[3]); - DONE; + enum memmodel model = memmodel_from_int (INTVAL (operands[3])); + if (is_mm_relaxed (model)) + return "swp\t%2, %0, %1"; + else if (is_mm_acquire (model) || is_mm_consume (model)) + return "swpa\t%2, %0, %1"; + else if (is_mm_release (model)) + return "swpl\t%2, %0, %1"; + else + return "swpal\t%2, %0, %1"; } ) @@ -585,28 +588,6 @@ ;; ARMv8.1-A LSE instructions. -;; Atomic swap with memory. -(define_insn "@aarch64_atomic_swp" - [(set (match_operand:ALLI 0 "register_operand" "+&r") - (match_operand:ALLI 1 "aarch64_sync_memory_operand" "+Q")) - (set (match_dup 1) - (unspec_volatile:ALLI - [(match_operand:ALLI 2 "register_operand" "r") - (match_operand:SI 3 "const_int_operand" "")] - UNSPECV_ATOMIC_SWP))] - "TARGET_LSE && reload_completed" - { - enum memmodel model = memmodel_from_int (INTVAL (operands[3])); - if (is_mm_relaxed (model)) - return "swp\t%2, %0, %1"; - else if (is_mm_acquire (model) || is_mm_consume (model)) - return "swpa\t%2, %0, %1"; - else if (is_mm_release (model)) - return "swpl\t%2, %0, %1"; - else - return "swpal\t%2, %0, %1"; - }) - ;; Atomic load-op: Load data, operate, store result, keep data. (define_insn "@aarch64_atomic_load"