From patchwork Thu Aug 17 01:17:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick O'Neill X-Patchwork-Id: 135837 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp388064vqi; Wed, 16 Aug 2023 18:18:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGtbghzwAW9zc0LJnVl7f4j3PPP1uYIv/DmxmfVMQg59TSoAUyLdg9VbmM4b7GZkCffPq9n X-Received: by 2002:a2e:a0d8:0:b0:2b9:acad:b4ab with SMTP id f24-20020a2ea0d8000000b002b9acadb4abmr2600532ljm.28.1692235093516; Wed, 16 Aug 2023 18:18:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692235093; cv=none; d=google.com; s=arc-20160816; b=v3mO6U82y3DmHOPvCKuXTvsux6wlWu7hf9iVbwybw5x3PSKfnBUiV87bBo9jdyAiAL fspfdQf/oZRxf356QZiIBUlV6PZFHLn94w4sOPiokdkvdtiJLo+EF6ZclE6WKtk35dP8 Cy4y9Qnu1xEdK5R9audHDMtHLJTzwo79z1OxxKMrw/lOGLcCt3XB+hPqe4EMU7s97i4K +E3bBjhOl0YWwJhJD/xsu1WJy4N6cP0/H8u/tgap2e//N39VMC3Eex7NF2Edwohvz9Vj eu8hpHBLfMwfamBSphID6QWZX1Jl6h0T4Patuqfw8saK3492wTF7xGzr1e7VcnHk19xx X++Q== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dmarc-filter:delivered-to; bh=4DZ3F+/Rq2/glNphffGh5KApuzqLKjRapBOcilHRNzU=; fh=GYy/4vGz55TEz/EJI0anNGmCsk5eo2bC6Xu9/KWsuf8=; b=mOLQui6aKZ43UblK2nykqc6VSQm1ROEZQ8FTKRd22r9MdSK0yVI29s0DBoDtHGrzG/ iBC2BeCEuwY7iPOKJaqA9dI0FTZe8Hw3RN8CcitBfVEaoCEULTUcuP/LjplVWfwV//d5 Hkg5k/nuCxS/T/QhxRBZH9+WsRH7cP4OP1+hwyKZ+lGQLE2TE7DjiQ6Ohv35/lXr9/xT ZriKgIthOeaOT86/eoRShZ/v0LTNkq26z1IZfGwPzJfurMp6is7y5N6LaQN17J8/X6SN pbsEXqQ7foZFNwlMkG8uL9GTkA7OXpj9qUC3e4Tj3HoM+HfkSxIrlm87Kczk5hyvKtr5 YYlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=bjf7S8jO; 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 j16-20020a1709064b5000b0099845f6579csi11608602ejv.631.2023.08.16.18.18.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 18:18:13 -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=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=bjf7S8jO; 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 2AC053854830 for ; Thu, 17 Aug 2023 01:18:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by sourceware.org (Postfix) with ESMTPS id 450D43858C2C for ; Thu, 17 Aug 2023 01:17:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 450D43858C2C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pf1-x443.google.com with SMTP id d2e1a72fcca58-68879fc4871so1369957b3a.0 for ; Wed, 16 Aug 2023 18:17:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1692235057; x=1692839857; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4DZ3F+/Rq2/glNphffGh5KApuzqLKjRapBOcilHRNzU=; b=bjf7S8jOhwbWIMfAfwXCPolXC+slPNABl2lxIaGsC3e3dOfvEjsLPr5n+0dJECrFOz EEA1/Mfv+MiMfL0W+hwcyqyre5YD6aWMaDiDHr/OXRdqNDgZGZbiP/Nrc0GTkE/wk0XF zja1DOrYofG9b0PFn/prC/6HiueSnUYhEem8w6RrY82e6sCQybG4FPLKLmyX9YH4+bqS /dZ8OQhuAbtTEnd2Lk4twGmcrqGqcnx3gczKzRvOV9+xGoWKOZCIhSocYL9AuvPsna6D iUP8ZtjuNfRcNXVZqd8GbbemlLKa7YvDXb8NY5iGYejJO8NhXYhGlx8G4ehLQNBf7v5+ gt6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692235057; x=1692839857; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4DZ3F+/Rq2/glNphffGh5KApuzqLKjRapBOcilHRNzU=; b=UEQAdHvIczUJ5c0uQLMksSH2sxfx3WphueyBOWcaDvLQzfBkOvLN9JfBEd/0Otsu9e Zmym3NIGQa19yeGxtyUqidz3+1TgYY08MFsS3WHarO2BLHAIwpiRYpovWix5/be0YWyR 0BktQTlfeaQs20e8Daj+2rvQZiNx0uc9Cq5jGl/sjBQoPVrWlXos19PSs19+fUTmZjD6 v0+XaOnL426YLBIUp4E8Jn/4JlizMOy5MvYzWYTxtClde8jA8sVXfKXdRgqzkAyGFyYB D7gzbvN1uyzK/OeCFooXXWRaAum2JW0nlSU8i0T698AEMhGLA9WHgGBTB9uzyxlFRKjk eRhQ== X-Gm-Message-State: AOJu0Ywt8Mh7ardjY1LjfgOY+rC2xpA66eNWLILJtC0eSy63ZFa9Laa2 qV+2Dj6q8IWZB8uO/uFoN4mbMUelwN9Fa9Yup2wOhHJL X-Received: by 2002:a05:6a20:3c91:b0:134:a478:5e4a with SMTP id b17-20020a056a203c9100b00134a4785e4amr4377399pzj.17.1692235057005; Wed, 16 Aug 2023 18:17:37 -0700 (PDT) Received: from patrick-ThinkPad-X1-Carbon-Gen-8.hq.rivosinc.com ([50.221.140.188]) by smtp.gmail.com with ESMTPSA id u18-20020aa78492000000b00689e910ddd9sm139594pfn.57.2023.08.16.18.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 18:17:36 -0700 (PDT) From: Patrick O'Neill To: gcc-patches@gcc.gnu.org, pinskia@gmail.com Cc: wangfeng@eswincomputing.com, jeffreyalaw@gmail.com, gnu-toolchain@rivosinc.com, palmer@rivosinc.com, charlie@rivosinc.com, Patrick O'Neill Subject: [PATCH v2] RISCV: Add rotate immediate regression test Date: Wed, 16 Aug 2023 18:17:29 -0700 Message-Id: <20230817011729.324315-1-patrick@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816231403.321156-1-patrick@rivosinc.com> References: <20230816231403.321156-1-patrick@rivosinc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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: INBOX X-GMAIL-THRID: 1774437105340676534 X-GMAIL-MSGID: 1774437105340676534 This adds new regression tests to ensure half-register rotations are correctly optimized into rori instructions. gcc/testsuite/ChangeLog: * gcc.target/riscv/zbb-rol-ror-08.c: New test. * gcc.target/riscv/zbb-rol-ror-09.c: New test. Co-authored-by: Charlie Jenkins Signed-off-by: Patrick O'Neill --- Trunk optimized these added testcases correctly. GCC 13.2 and earlier do not optimize these cases correctly. Expands on testcases added in: https://gcc.gnu.org/git/?p=gcc.git;a=commit;f=gcc/testsuite/gcc.target/riscv/zbb-rol-ror-04.c;h=0ccf520d349a82dafca0deb3d307a1080e8589a0 --- V2 Changes: Move testcases to new files. --- .../gcc.target/riscv/zbb-rol-ror-08.c | 25 +++++++++++++++++++ .../gcc.target/riscv/zbb-rol-ror-09.c | 15 +++++++++++ 2 files changed, 40 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/zbb-rol-ror-08.c create mode 100644 gcc/testsuite/gcc.target/riscv/zbb-rol-ror-09.c diff --git a/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-08.c b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-08.c new file mode 100644 index 00000000000..30696f3bb32 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-08.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_zbb -mabi=lp64d -fno-lto -O2" } */ +/* { dg-skip-if "" { *-*-* } { "-g" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ +/* { dg-final { scan-assembler-not "and" } } */ + +/* +**foo1: +** rori a0,a0,32 +** ret +*/ +unsigned long foo1(unsigned long rotate) +{ + return (rotate << 32) | (rotate >> 32); +} + +/* +**foo2: +** roriw a0,a0,16 +** ret +*/ +unsigned int foo2(unsigned int rotate) +{ + return (rotate << 16) | (rotate >> 16); +} diff --git a/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-09.c b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-09.c new file mode 100644 index 00000000000..a3054553e18 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-09.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gc_zbb -mabi=ilp32 -fno-lto -O2" } */ +/* { dg-skip-if "" { *-*-* } { "-g" } } */ +/* { dg-final { check-function-bodies "**" "" } } */ +/* { dg-final { scan-assembler-not "and" } } */ + +/* +**foo1: +** rori a0,a0,16 +** ret +*/ +unsigned int foo1(unsigned int rs1) +{ + return (rs1 << 16) | (rs1 >> 16); +}