From patchwork Sun Nov 13 23:05:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christoph_M=C3=BCllner?= X-Patchwork-Id: 1578 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1865044wru; Sun, 13 Nov 2022 15:07:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf59KHBFanOwlByvLUKo/SaQvpi4oxSxTdT0sEt+aXYCnekvqxcuukPQ3RXPQ10WveWPS1sg X-Received: by 2002:a17:906:8385:b0:7ad:8035:ae3d with SMTP id p5-20020a170906838500b007ad8035ae3dmr8597012ejx.46.1668380831872; Sun, 13 Nov 2022 15:07:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668380831; cv=none; d=google.com; s=arc-20160816; b=xRxcOF/0UYeXtnFgCshX4tRodygspISOcOY1SHvddRcuqh3ejRpxTK8m3dAas2kKrt fxKhoE1iiTj8msMC3pT4Ycc7wkmfCIDxvZwXUnqPl/r2/HKL9brJpmcAdyLDybMGIdFa +UIvKeUQXgiYYis58FcsoM6zUWGZv6VwDItElxT51YTyHfCngmSUtve/7Nd3qYtwKNFb hZOQHehXKpCUq4edCLRnnyzvtEwTBsRzp/Mutjwp1edpXqQLWQV/e0LCOzUmUCAO/pDW EZg5sE7AuFp3Ryt9xXjZgBQNYXhVpC+QopKEMZgpcMmmUQUxGxkKQUXByiu3q1StmnoU bNYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender: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 :dmarc-filter:delivered-to; bh=5zzMbr9NoCAKwCc000hD7UZqvh9CcKnww1Z65G6M7O8=; b=jIkIg+R0nUfKi1cp1NQqwdEHKthTpnOX8xYkGpDcHqWVojCRYwbLHakTOmnrSbAX4G RfrvAIT6gjLeuyyeZxDuiywkubjQLgOympt+insaZVREhWR0QKM07yZrit677Lt+YD42 Ok5wPjwvNt/VgJtQ3NdpMK7YKUDqi56f32TJMBtTO+3zoXPNTWtTggkE3yuu4+YNPdM3 laGW2NPVLUGcjz5tHOSEKbOwHTJ7CJbIICGBFcHxbhRFTHkgCLTUe4teLAWYWVLSk0o8 FpBFnPWNOTGJQocmSeATnNVtZ/4Zblzcrf9IITenJFyVvPdF/5DNINq/1VaZXn4nwPEr 7X0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=V0Rhzm1x; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id e17-20020a17090658d100b0077f92be81adsi9075545ejs.212.2022.11.13.15.07.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Nov 2022 15:07:11 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=V0Rhzm1x; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 6E4B938A815E for ; Sun, 13 Nov 2022 23:06:09 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id 4875C3857BB3 for ; Sun, 13 Nov 2022 23:05:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4875C3857BB3 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu Received: by mail-ej1-x636.google.com with SMTP id n12so24365036eja.11 for ; Sun, 13 Nov 2022 15:05:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5zzMbr9NoCAKwCc000hD7UZqvh9CcKnww1Z65G6M7O8=; b=V0Rhzm1xgXyrqtEmzSQc6OAmQF6cuJxBPBJURy8ZyumJB9tMiktT/FaV9xCDOrt2fr 9Bzg0bOu2yt58VQyqtzl7ck5d0r8GqMO5Li0fEec0STt/R2sCS0ErcVuSwS1+gXk75Qm BXg287dl7NZmmLmqMZ/5Z6XwWLf1eezhCq8jhxe7YyKiELXB5/5EAsoOo7OAdIdUhM/8 ZHL2M4tpMPJKwEQO4eiyV/XzXzByW/a/pmrKII0uCU6hqt50WkRliSaO0/jlXyP5oSho 3m+zu84fYT7QFLB6StP0/ElE5Jrw0gcaeGRt+/GXdn182LTDJdC1YokXm9zrx35ACxFx lSOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=5zzMbr9NoCAKwCc000hD7UZqvh9CcKnww1Z65G6M7O8=; b=kLE8JZ2f8ftnkbRShybL4V0nrYRPuyG356G3oiwSLC2L99e8LMEhOjQ1gYdJDL9jLn Jj/XKiQQYIIKL6QI9+4VOjzlqJHxJ5wBiNVUeV+rWkgMAHgtOpt0H5wSiCu7WKdnQLuN SiW1qwRdhcOHe7oA6mp3JS1MmoTuy8ohdiTft29EuEP2EM1gPwmw1Y9/db5r9irrwJxf DGoTHCWchpVipAtYMHZ9qYwOtZcnopYLNFM71gpN+jTf1P/IKJ45Tp9pd8nhbdZ+iX17 nJ5oZnxsy280F0+eZi8H5PL4cFwDTszDLz8g5y52RAtsIHyRLnw0CDm2afYLbwYlysOK LLxA== X-Gm-Message-State: ANoB5pk4LHV0vWvc/Mu09uCNQz6EVwlMsdy86XfSnFyDbBO/yvH60C48 gSHT7ZUNUcazVnSy6XLdo/xD7cjwHnJ0jYjP X-Received: by 2002:a17:907:9258:b0:78d:8dfb:10ad with SMTP id kb24-20020a170907925800b0078d8dfb10admr9007745ejb.289.1668380724747; Sun, 13 Nov 2022 15:05:24 -0800 (PST) Received: from beast.fritz.box (62-178-148-172.cable.dynamic.surfer.at. [62.178.148.172]) by smtp.gmail.com with ESMTPSA id ku3-20020a170907788300b007ae21bbdd3fsm2361281ejc.162.2022.11.13.15.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Nov 2022 15:05:24 -0800 (PST) From: Christoph Muellner To: gcc-patches@gcc.gnu.org, Kito Cheng , Jim Wilson , Palmer Dabbelt , Andrew Waterman , Philipp Tomsich , Jeff Law , Vineet Gupta Cc: =?utf-8?q?Christoph_M=C3=BCllner?= Subject: [PATCH 0/7] riscv: Improve builtins expansion Date: Mon, 14 Nov 2022 00:05:14 +0100 Message-Id: <20221113230521.712693-1-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749424099077897694?= X-GMAIL-MSGID: =?utf-8?q?1749424099077897694?= From: Christoph Müllner This patchset adds includes patches to improve the following builtin expansions: * cpymemsi: Allow by-pieces to generate overlapping memory accesses * cmpstrsi: Add expansion for strcmp and strncmp for aligned strings when zbb/orc.b is available * strlen: Add expansion for strlen when zbb/orc.b is available This changes were inspired a lot by the PowerPC backend (e.g. moving the expansion code into riscv-string.cc and emitting an unrolled loop which eventually calls the C runtime if necessary). This series is meant to be applied on top of the VT1 support series: https://gcc.gnu.org/pipermail/gcc-patches/2022-November/605959.html The patches come with their own tests and show no regressions to existing tests. Further the series has been tested with all SPEC CPU2017 benchmarks. Christoph Müllner (6): riscv: bitmanip/zbb: Add prefix/postfix and enable visiblity riscv: Enable overlap-by-pieces via tune param riscv: Move riscv_block_move_loop to separate file riscv: Use by-pieces to do overlapping accesses in block_move_straight riscv: Add support for strlen inline expansion riscv: Add support for str(n)cmp inline expansion Philipp Tomsich (1): riscv: bitmanip: add orc.b as an unspec gcc/config.gcc | 3 +- gcc/config/riscv/bitmanip.md | 12 +- gcc/config/riscv/riscv-protos.h | 7 +- gcc/config/riscv/riscv-string.cc | 687 ++++++++++++++++++ gcc/config/riscv/riscv.cc | 172 +---- gcc/config/riscv/riscv.md | 105 ++- gcc/config/riscv/riscv.opt | 5 + gcc/config/riscv/t-riscv | 4 + .../gcc.target/riscv/memcpy-nonoverlapping.c | 54 ++ .../gcc.target/riscv/memcpy-overlapping.c | 47 ++ .../gcc.target/riscv/memset-nonoverlapping.c | 45 ++ .../gcc.target/riscv/memset-overlapping.c | 43 ++ .../gcc.target/riscv/zbb-strcmp-unaligned.c | 36 + gcc/testsuite/gcc.target/riscv/zbb-strcmp.c | 55 ++ .../gcc.target/riscv/zbb-strlen-unaligned.c | 13 + gcc/testsuite/gcc.target/riscv/zbb-strlen.c | 18 + 16 files changed, 1132 insertions(+), 174 deletions(-) create mode 100644 gcc/config/riscv/riscv-string.cc create mode 100644 gcc/testsuite/gcc.target/riscv/memcpy-nonoverlapping.c create mode 100644 gcc/testsuite/gcc.target/riscv/memcpy-overlapping.c create mode 100644 gcc/testsuite/gcc.target/riscv/memset-nonoverlapping.c create mode 100644 gcc/testsuite/gcc.target/riscv/memset-overlapping.c create mode 100644 gcc/testsuite/gcc.target/riscv/zbb-strcmp-unaligned.c create mode 100644 gcc/testsuite/gcc.target/riscv/zbb-strcmp.c create mode 100644 gcc/testsuite/gcc.target/riscv/zbb-strlen-unaligned.c create mode 100644 gcc/testsuite/gcc.target/riscv/zbb-strlen.c