Message ID | 20231020095348.2455729-1-christoph.muellner@vrull.eu |
---|---|
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp939845vqb; Fri, 20 Oct 2023 02:54:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEpGV5I6H+cy4nu/WZzMAjEWGEdkZ+85GH57rSGqOHKj2Ry5uSQ+F8HNqGid85ACFuWujrz X-Received: by 2002:a05:620a:170f:b0:76f:1817:942b with SMTP id az15-20020a05620a170f00b0076f1817942bmr1198153qkb.28.1697795663077; Fri, 20 Oct 2023 02:54:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697795663; cv=pass; d=google.com; s=arc-20160816; b=miJqjC+tJ72xvNDhBEcKVafW/WbMaKKAqj7fUuR9rB+cqMWfHqbXkOclgukRIJJ9Yi DNlgthuJYrD0qdla786KIb+tAEUB/i/MADloLyLJwB8nCwqCV3Sa0mb7Xo8KsrAKWMmI 60vWGPoh1rV7+CZLTsrPSDfxkLRRYqcBFHSVy9/iGPdvHgpECYj/aoyNiCHYNycmRijp LqKi3j+ZEQgCwFA46CswvEOTdCHc2T1cs05fDPKrRsuFs6B2LaY9ofJ4DmizFOarqURh B9BwsjG/MLH9Zq3pwcM6XZzT1rOC938d+T05EiYRNaVZMYLat58M7nRkiAXwS1p5hc7w fGbQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=wopUc3b9txS1pPPpbBT9qfX9RabZkRtIRWCRtKhTG/s=; fh=9oFhVPKihcNP6VY2Nsu6+FGvAEKY/HNABCPdk6S267g=; b=B4Se8pF2K+ctxv9VJ2EYfc1VGPPWv+RzOkFXWT/67Os8tecq/pZ1qrUhR0wMDO/sYs ZL5ru63ZMkbg75sWR2N2duIp6vRiJA8Rg9WOfTUaKjVpnCoKEU5kQsWNbFfdCmFilc0l XbWhHwBtrDrqLJbc8cCBxlukwHsOLznPLL0CyAoFC6+fMH8zftVG4Vxp0UuhpehqAI17 UbQUhhWEcD3ZNGlOPybmGxu+5MqCQmwI6X2gb21zTqc19Ew8XD7m1E5Hb5mSga2E0aQp tF1YK6jyG0pALPXv4J7oZ177DJ/UgXjCAcLr5f5UbJrkT2X34vzVNgvW52fKE9UwAv6U lIyw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=XBcmlOLg; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id d4-20020a05620a204400b0076f280e295fsi962423qka.429.2023.10.20.02.54.23 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 02:54:23 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=XBcmlOLg; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 92A713858431 for <ouuuleilei@gmail.com>; Fri, 20 Oct 2023 09:54:21 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id 83D203858D39 for <gcc-patches@gcc.gnu.org>; Fri, 20 Oct 2023 09:53:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 83D203858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 83D203858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697795636; cv=none; b=xwGiIYiYutFqS61hixJnUxZH87YUaT8VdbrNnzaxhKQCfJDrcSS4AfGsDc1gRXgXWAgb+h1iXi0idsKVNxkMsahsdx+0zBBKARhAT3Yxd1CeTrpoHx1LWyrQakJuzjkNXv3PJxM7gmn9ww78KB6N1ohKWbP7EAPXVPa2mkrG52k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697795636; c=relaxed/simple; bh=T/CGykjARvDlE6vjTAPQzlv+mWGLWEydgUtDQk5s118=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=lGQT39fa8Cfq6gukiY3Ok6R4pxYiF+mpYDPi5B/mXZcV+9rJ4IE7tZseiCLOveODIBkg78DvUtWOJ6kIQ8K9DoWP8L9b0+S40nJdvwmt3ujtvz+DR/q8bWa5mj1khsICRL8UF7gO2VwL0Fuzm7yuDfbc4bV2o35k4u214Gq4fnU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-53e751aeb3cso861027a12.2 for <gcc-patches@gcc.gnu.org>; Fri, 20 Oct 2023 02:53:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1697795633; x=1698400433; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wopUc3b9txS1pPPpbBT9qfX9RabZkRtIRWCRtKhTG/s=; b=XBcmlOLgI5yGv0AgacTdc6ceEv0o5PglIDK3PwVeBR89DLKyLij4Zfe3ZyBDL8p7gA RBk2M/w5Tr+ECrrmedOkHavThhafZcOh8DSu9psv9G+cYzlEurYI2sndvecDgHw+BqcW BmM3nshg4y332hgFl21wPJ4DmxfIH6gWzOaRBAjpACsVKTFyhLTjTGxiLuVy8EBBVTNl bMOSZG6KiqmGoIOo0fVGIjMDectov3iOg+jhyMEVlOk/6zLbbrucdGrS6Fxv3WZGD0xB zmXTjZxT2nfswsFl1AV3xsjoPtgs53rGpX1yOfAL0X3fOJJrNtUIb05C7wxiAyjEr/EE pRxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697795633; x=1698400433; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wopUc3b9txS1pPPpbBT9qfX9RabZkRtIRWCRtKhTG/s=; b=ZXEV3L+ahc/apsTzxjNsUGuoitN5Fpl6L74dxG4Vc0TQVrI7IincrIWX3ebHRVjf2q RFb12AQP+W+DF577bOwhmsznnPT0wjPlgYnZFo+DKG5mLELzCyqdmF+myBR6FeJ11sOZ mm3+ZKKCDzkLu1ArIdgdYdQKIxGyWCZqRUhSevRjLsFwqXMJ8FWwXiuzClIYP3cXZZJA WgMSzOpj8uG7nXOvL9PwmQn8Fd4ZuCAvH1VnAQV8wBeTIcJU8dvhpkUP0jkU3cjsTgsp UsjCgvTuMYSNkLv5Ezraq2bqvWpZHM5NDIyFM49R6JjrdwjNXJWsMs9jWfcrN69LarSY 39aw== X-Gm-Message-State: AOJu0YxpA6sEAQswnDUwx/ztlBgNx1cEOG8P3aXMnXhcXRv9eUXVvZbl +zv0SlJJiahyKawGRIszGYJR1h8Uc7YCtVCs5h8= X-Received: by 2002:a05:6402:4305:b0:53e:7ec9:753d with SMTP id m5-20020a056402430500b0053e7ec9753dmr1021484edc.27.1697795632615; Fri, 20 Oct 2023 02:53:52 -0700 (PDT) Received: from beast.fritz.box (62-178-148-172.cable.dynamic.surfer.at. [62.178.148.172]) by smtp.gmail.com with ESMTPSA id w21-20020a50d795000000b0053e4d1cbc6esm1147688edi.55.2023.10.20.02.53.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 02:53:51 -0700 (PDT) From: Christoph Muellner <christoph.muellner@vrull.eu> To: gcc-patches@gcc.gnu.org, Kito Cheng <kito.cheng@sifive.com>, Jim Wilson <jim.wilson.gcc@gmail.com>, Palmer Dabbelt <palmer@dabbelt.com>, Andrew Waterman <andrew@sifive.com>, Philipp Tomsich <philipp.tomsich@vrull.eu>, Jeff Law <jeffreyalaw@gmail.com> Cc: =?utf-8?q?Christoph_M=C3=BCllner?= <christoph.muellner@vrull.eu> Subject: [PATCH v2 0/2] riscv: Adding support for XTHead(F)MemIdx Date: Fri, 20 Oct 2023 11:53:46 +0200 Message-ID: <20231020095348.2455729-1-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, JMQ_SPF_NEUTRAL, KAM_MANYTO, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780267785386725271 X-GMAIL-MSGID: 1780267785386725271 |
Series |
riscv: Adding support for XTHead(F)MemIdx
|
|
Message
Christoph Müllner
Oct. 20, 2023, 9:53 a.m. UTC
From: Christoph Müllner <christoph.muellner@vrull.eu>
This two patches add support for the XTheadMemIdx
and XTheadFMemIdx ISA extensions, that support additional
addressing modes. The extensions are implemented in a range
of T-Head cores (e.g. C906, C910, C920) and are available
on the market for quite some time.
The ISA spec can be found here:
https://github.com/T-head-Semi/thead-extension-spec
An initial version of these patches has been sent a while ago.
Jeff Law suggested to use INSNs instead of peepholes to let
the combiner do the optimization. This is the major change
that this patches have seen.
Both patches come with their own tests and don't introduce
any regressions for RV32 or RV64. Further the patches did
not show any issues with SPEC CPU 2017 (base&peak) using
multiple combinations of XThead* extensions.
The patches have been tested on QEMU and a C920-based machine.
Changes in v2:
* Convert peepholes to INSNs (let the combiner do the work)
* Enable XTheadFMemIdx optimizations only if XTheadMemIdx is available
(to address the case when GP regs are used in FP mode (e.g. (reg:DF a2))
* Add a insn_and_split (th_memidx_operand) to address the case when
reload splits off the index calculation.
Christoph Müllner (2):
riscv: thead: Add support for the XTheadMemIdx ISA extension
riscv: thead: Add support for the XTheadFMemIdx ISA extension
gcc/config/riscv/constraints.md | 26 +
gcc/config/riscv/riscv-protos.h | 29 +
gcc/config/riscv/riscv.cc | 24 +-
gcc/config/riscv/riscv.h | 6 +-
gcc/config/riscv/riscv.md | 26 +-
gcc/config/riscv/thead.cc | 485 ++++++++++++++
gcc/config/riscv/thead.md | 594 +++++++++++++++++-
.../riscv/xtheadfmemidx-index-update.c | 20 +
.../xtheadfmemidx-index-xtheadbb-update.c | 20 +
.../riscv/xtheadfmemidx-index-xtheadbb.c | 22 +
.../gcc.target/riscv/xtheadfmemidx-index.c | 22 +
.../riscv/xtheadfmemidx-uindex-update.c | 20 +
.../xtheadfmemidx-uindex-xtheadbb-update.c | 20 +
.../riscv/xtheadfmemidx-uindex-xtheadbb.c | 24 +
.../gcc.target/riscv/xtheadfmemidx-uindex.c | 25 +
.../gcc.target/riscv/xtheadmemidx-helpers.h | 152 +++++
.../riscv/xtheadmemidx-index-update.c | 27 +
.../xtheadmemidx-index-xtheadbb-update.c | 27 +
.../riscv/xtheadmemidx-index-xtheadbb.c | 36 ++
.../gcc.target/riscv/xtheadmemidx-index.c | 36 ++
.../riscv/xtheadmemidx-modify-xtheadbb.c | 74 +++
.../gcc.target/riscv/xtheadmemidx-modify.c | 74 +++
.../riscv/xtheadmemidx-uindex-update.c | 27 +
.../xtheadmemidx-uindex-xtheadbb-update.c | 27 +
.../riscv/xtheadmemidx-uindex-xtheadbb.c | 44 ++
.../gcc.target/riscv/xtheadmemidx-uindex.c | 44 ++
26 files changed, 1917 insertions(+), 14 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadfmemidx-index-update.c
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadfmemidx-index-xtheadbb-update.c
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadfmemidx-index-xtheadbb.c
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadfmemidx-index.c
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadfmemidx-uindex-update.c
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadfmemidx-uindex-xtheadbb-update.c
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadfmemidx-uindex-xtheadbb.c
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadfmemidx-uindex.c
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadmemidx-helpers.h
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadmemidx-index-update.c
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadmemidx-index-xtheadbb-update.c
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadmemidx-index-xtheadbb.c
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadmemidx-index.c
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadmemidx-modify-xtheadbb.c
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadmemidx-modify.c
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadmemidx-uindex-update.c
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadmemidx-uindex-xtheadbb-update.c
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadmemidx-uindex-xtheadbb.c
create mode 100644 gcc/testsuite/gcc.target/riscv/xtheadmemidx-uindex.c
Comments
On 10/20/23 03:53, Christoph Muellner wrote: > From: Christoph Müllner <christoph.muellner@vrull.eu> > > This two patches add support for the XTheadMemIdx > and XTheadFMemIdx ISA extensions, that support additional > addressing modes. The extensions are implemented in a range > of T-Head cores (e.g. C906, C910, C920) and are available > on the market for quite some time. > > The ISA spec can be found here: > https://github.com/T-head-Semi/thead-extension-spec > > An initial version of these patches has been sent a while ago. > Jeff Law suggested to use INSNs instead of peepholes to let > the combiner do the optimization. This is the major change > that this patches have seen. Did you happen to do any before/after testing? And if so, did using the combiner help with discovery of these cases? I would expect it to have done so, but it's always nice to have a confirmation. If not, no big deal from a review standpoint. Given I looked at these before, I'll take this small kit again. Jeff
On Fri, Oct 20, 2023 at 4:33 PM Jeff Law <jeffreyalaw@gmail.com> wrote: > > > > On 10/20/23 03:53, Christoph Muellner wrote: > > From: Christoph Müllner <christoph.muellner@vrull.eu> > > > > This two patches add support for the XTheadMemIdx > > and XTheadFMemIdx ISA extensions, that support additional > > addressing modes. The extensions are implemented in a range > > of T-Head cores (e.g. C906, C910, C920) and are available > > on the market for quite some time. > > > > The ISA spec can be found here: > > https://github.com/T-head-Semi/thead-extension-spec > > > > An initial version of these patches has been sent a while ago. > > Jeff Law suggested to use INSNs instead of peepholes to let > > the combiner do the optimization. This is the major change > > that this patches have seen. > Did you happen to do any before/after testing? And if so, did using the > combiner help with discovery of these cases? I would expect it to have > done so, but it's always nice to have a confirmation. I had no doubt this would be equal or better, therefore I did not plan to do that. However, measuring this is not that hard, so I just did the exercise of forward-porting the peephole-based patchset (and all tiny fixes that the v2 has). I then built xalancbmk_r/peak (randomly selected) with both compilers and compared the number of indexed loads and indexed stores in the binary: v1: 3982 indexed loads / 2447 indexed stores v2: 4110 indexed loads (+3.2%) / 2476 indexed stores (+1.2%) So your suggestion indeed helps to discover additional cases. Thanks again for that! BR Christoph