From patchwork Wed Sep 26 05:03:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147529 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp261607lji; Tue, 25 Sep 2018 22:04:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV61BErZJh79Yrm52p3rXkaGEcIwY4Yq2MMW4FJxlKsm6n74t8GXMXdt+xSN/3sbFObaa1wjX X-Received: by 2002:a63:2c8e:: with SMTP id s136-v6mr4028911pgs.390.1537938256066; Tue, 25 Sep 2018 22:04:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537938256; cv=none; d=google.com; s=arc-20160816; b=Bkd+cx8YANCIbAoBJ1pZFx1Dpgn/BsVk413P1iLPGhwiRPeCmCsI5b52CHZJxQkAb/ LkrG1My7PGyW//mAP2I/UmOSSbXz6/lWoVQXpEIUI4AgbEhFchJjwoyp1Scl3UP8jFhu 6El/CwosqoLY5MCPO839ENzQmOZ0zHgWWc0Z1BiEMawAgrC3x2WWRe/Tg/eJihL4AueV FgofbaUEVQWP/Xq6f0OfEykSjAqaMS+hnDyumQo9KzM+VPzhjm4HTau/UMHqW7wB5xH0 KAd4M525Ioid8sCu3Qfv4/wNYd6whCs4pWQ3GRgYkpl3IAuF21rA7aNPxLg+vbkmK4pg 9Hvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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=9idq6z+0b3HFT7/O2UjcIAJUudWmxwF8Z6g0hZfLBjw=; b=zCnOwiOzAZ/fOTEJIv0Q82OtDTSQq2qprqKkE1ixBGD0udAjHbjoxUgUe7ma+OH6IN rDBGouzEiJwckPQhqn3oJ07J4ZvIT28IswHaLtOwrGCBSod6I1P4RBL0/HOzj5Fb413+ +YcBQ3ZDSm4BnUJlr12ih8Bc0hhKX/Q/e+rTbrZ1dB7BtcfB6PJ7+n/NvGbKNb08l0ES eOJ5bUwC+Mvd1KWivJDV+bAEQDwx/eYhUbRY58vS5FzF/odOoRl8VRFq9PdJxQl+p8+S qL+N+05GLW7Y9wHAidJr9dG/QaGkwmWrxMpJzRLdOINw38/Hz0DAu/Gvlh3ycNvynJAk N/fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dEkDr5O0; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SYhZVUtK; spf=pass (google.com: domain of gcc-patches-return-486382-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-486382-patch=linaro.org@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id j12-v6si711266pfd.222.2018.09.25.22.04.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Sep 2018 22:04:16 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-486382-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=dEkDr5O0; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SYhZVUtK; spf=pass (google.com: domain of gcc-patches-return-486382-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-486382-patch=linaro.org@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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; q=dns; s=default; b=dYeZvdKRzbeI c4Z4KGmTMI8i2zj12ukvKys7q9Nx2syWpwL99bk6YCobPbbl//RIOMkC9/eplNs+ 7IJUZMcVpgS4b7JLWkLc+6E7EI4vZeIRg3jmdwL3rxRcz6yTbuLdK1chlab8qfAE 3+qrNvsfdsKWyd7RveNIZVGmPHWAm00= 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; s=default; bh=lN2l8S8tiFWCGyn4NU Kauvv1ISw=; b=dEkDr5O0VbWINA+aFk4GdvqKkJCLhXpaVrtKwvSkzm7BTY5q6b 90ELVONVT27IJ8mZXY6LTD7w+uoQpNRsUSOMvShM43TpI+8YpIw1TmHuPSsjTP0f V98tK8W412Bmxgr7M4BC8qZchzOVaz8HPhOHFVoNFuTG+M0b6ywQmaS+U= Received: (qmail 73188 invoked by alias); 26 Sep 2018 05:04:02 -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 72873 invoked by uid 89); 26 Sep 2018 05:04:01 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.7 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Connect, UD:host, proved X-HELO: mail-pg1-f177.google.com Received: from mail-pg1-f177.google.com (HELO mail-pg1-f177.google.com) (209.85.215.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 26 Sep 2018 05:03:59 +0000 Received: by mail-pg1-f177.google.com with SMTP id z3-v6so8243271pgv.8 for ; Tue, 25 Sep 2018 22:03:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=9idq6z+0b3HFT7/O2UjcIAJUudWmxwF8Z6g0hZfLBjw=; b=SYhZVUtK7xf3tlA1yTeIohRKHKzZ7GAwav11i7uxgpNpR8PWCXkbNafmQXzrIIEnCn RdwjgV8Ut1EGz1+V/u2ELJUYWImQIg9+7ELM5eHOIfxHIJrQGYGPuISpS9Bdrf2+LgE/ JJWP5V1VDQDGg0NbsepaUoVh6PEnt1tjRkk+zMgbm46f7GzF+ji06btYbUNgxC4PcO1f oY2TiQRlVFF3YVS11XQ3l6eEqSIINZxnQtWHmw9zW9KLCRBKsNYaS+YaggR4Yzw0Jjsi YDX8ZLf5ea+k+kab07x0IEa+OvaMKLyjpGi6k8AIshiqo+SRha1w7Uo9Ymsu15pKfow4 ha5A== Return-Path: Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id j22-v6sm4954650pfh.45.2018.09.25.22.03.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Sep 2018 22:03:56 -0700 (PDT) From: rth7680@gmail.com To: gcc-patches@gcc.gnu.org Cc: ramana.radhakrishnan@arm.com, agraf@suse.de, matz@suse.de, Richard Henderson Subject: [PATCH, AArch64 00/11] LSE atomics out-of-line Date: Tue, 25 Sep 2018 22:03:44 -0700 Message-Id: <20180926050355.32746-1-richard.henderson@linaro.org> From: Richard Henderson ARMv8.1 adds an (mandatory) Atomics extension, also known as the Large System Extension. Deploying this extension at the OS level has proved challenging. The following is the result of a conversation between myself, Alex Graf of SuSE, and Ramana Radhakrishnan of ARM, at last week's Linaro Connect in Vancouver. The current state of the world is that one could distribute two different copies of a given shared library and place the LSE-enabled version in /lib64/atomics/ and it will be selected over the /lib64/ version by ld.so when HWCAP_ATOMICS is present. Alex's main concern with this is that (1) he doesn't want to distribute two copies of every library, or determine what a resonable subset would be and (2) this solution does not work for executables, e.g. mysql. Ramana's main concern was to avoid the overhead of an indirect jump, especially in how that would affect the (non-)branch-prediction of the smallest implementations. Therefore, I've created small out-of-line helpers that are directly linked into every library or executable that requires them. There will be two direct branches, both of which will be well-predicted. In the process, I discovered a number of places within the code where the existing implementation could be improved. In particular: - the LSE patterns didn't use predicates or constraints that match the actual instructions, requiring unnecessary splitting. - the non-LSE compare-and-swap can use an extending compare to avoid requiring the input to have been previously extended. - TImode compare-and-swap was missing entirely. This brings aarch64 to parity with x86_64 wrt __sync_val_compare_and_swap. There is a final patch that enables the new option by default. I am not necessarily expecting this to be merged upstream, but for the operating system to decide what the default should be. It might be that this should be a configure option, so as to make that OS choice easier, but I've just now thought of that. ;-) I'm going to have to rely on Alex and/or Ramana to perform testing on a system that supports LSE. r~ Richard Henderson (11): aarch64: Simplify LSE cas generation aarch64: Improve cas generation aarch64: Improve swp generation aarch64: Improve atomic-op lse generation aarch64: Emit LSE st instructions Add visibility to libfunc constructors Link static libgcc after shared libgcc for -shared-libgcc aarch64: Add out-of-line functions for LSE atomics aarch64: Implement -matomic-ool aarch64: Implement TImode compare-and-swap Enable -matomic-ool by default gcc/config/aarch64/aarch64-protos.h | 20 +- gcc/optabs-libfuncs.h | 2 + gcc/common/config/aarch64/aarch64-common.c | 6 +- gcc/config/aarch64/aarch64.c | 480 ++++++-------- gcc/gcc.c | 9 +- gcc/optabs-libfuncs.c | 26 +- .../atomic-comp-swap-release-acquire.c | 2 +- .../gcc.target/aarch64/atomic-inst-ldadd.c | 18 +- .../gcc.target/aarch64/atomic-inst-ldlogic.c | 54 +- .../gcc.target/aarch64/atomic-op-acq_rel.c | 2 +- .../gcc.target/aarch64/atomic-op-acquire.c | 2 +- .../gcc.target/aarch64/atomic-op-char.c | 2 +- .../gcc.target/aarch64/atomic-op-consume.c | 2 +- .../gcc.target/aarch64/atomic-op-imm.c | 2 +- .../gcc.target/aarch64/atomic-op-int.c | 2 +- .../gcc.target/aarch64/atomic-op-long.c | 2 +- .../gcc.target/aarch64/atomic-op-relaxed.c | 2 +- .../gcc.target/aarch64/atomic-op-release.c | 2 +- .../gcc.target/aarch64/atomic-op-seq_cst.c | 2 +- .../gcc.target/aarch64/atomic-op-short.c | 2 +- .../aarch64/atomic_cmp_exchange_zero_reg_1.c | 2 +- .../atomic_cmp_exchange_zero_strong_1.c | 2 +- .../gcc.target/aarch64/sync-comp-swap.c | 2 +- .../gcc.target/aarch64/sync-op-acquire.c | 2 +- .../gcc.target/aarch64/sync-op-full.c | 2 +- libgcc/config/aarch64/lse.c | 280 ++++++++ gcc/config/aarch64/aarch64.opt | 4 + gcc/config/aarch64/atomics.md | 608 ++++++++++-------- gcc/config/aarch64/iterators.md | 8 +- gcc/config/aarch64/predicates.md | 12 + gcc/doc/invoke.texi | 14 +- libgcc/config.host | 4 + libgcc/config/aarch64/t-lse | 48 ++ 33 files changed, 1050 insertions(+), 577 deletions(-) create mode 100644 libgcc/config/aarch64/lse.c create mode 100644 libgcc/config/aarch64/t-lse -- 2.17.1