From patchwork Wed Aug 16 23:14:03 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: 135835 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp340939vqi; Wed, 16 Aug 2023 16:15:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4ksG/Q37q9mArz7Yxphek508n5jHpOIzeWGdkt+JxOfUfDc2h5CUiVhCAxCc20AElKCf3 X-Received: by 2002:a17:907:3f8f:b0:99c:572:c0e4 with SMTP id hr15-20020a1709073f8f00b0099c0572c0e4mr1296226ejc.7.1692227709116; Wed, 16 Aug 2023 16:15:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692227709; cv=none; d=google.com; s=arc-20160816; b=wZJhBf8nNIRbToKqVmq1rZ4k56aUKGFemsYQKjMLsZUv0W0dNNa98PAtCOK7vA5tt9 tV9uEEMUIjLqsTN86zCDknE4TX6bcH8HQPL/Tn2oNckd2ZyFw47dcBK4HwlYP3N2HvIn gQikWX24fD15XkA2fiTezrL12Oi1ADA5vZKDRgl7kH5BBjoNT5qW7Kd9r/lTFV/X5p/S pCMVD8/XG5SpdR8l4eGgEghSdLxlOEu9NpoqR+8VCPYUpnC53IwGJhmVCCsS7LcvzVoI 2G4wUveFluJA2Tnh9YZV3sUp6wRopIrvVjVz6IvAagcymUZWkDeEupDQkk2FCoIDcaTW JB9w== 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=8hsdKn/snGQKyMTV5QJchg+pS3CifPZdoLRL1nIb8ck=; fh=04r9lfOB0niPVt9i1TYu+opNQSxyK1jZWbuE3HHRZ04=; b=E3hTg1PrUwW4NpNc0s1hxaYSr8QHRhI7C1vj3A3C7uSjwaq05Japul+NcFlDVBQiUg NdZIwo0hsnfnUsfQNrbncCXm8hiT3s6w/LKAGhcdvcI7NyDhTa/zgvcndidY7A5o4aGz rhHjvY7eI/cgbKiaIK/MFaOEL387YD/rOkiO/RyvPJh8uQ48mY5JKnk6sdKvwA5YsNLf VmHK243xH19l0jZpmLX+RcssBkREJi2TamMlqbxmBe791JIWQxc1bElpRFb5zZ/o61LB fWFjpskpDGl3qm0PspZfm0xPujrIHHbWyU4xz8KRcS5DohcXkyngZKYDaIfBT9VciJnn wwhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=RqrnIkfS; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id me23-20020a170906aed700b00992a096678fsi11750345ejb.813.2023.08.16.16.15.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 16:15:09 -0700 (PDT) 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=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=RqrnIkfS; 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 5FC2838560A7 for ; Wed, 16 Aug 2023 23:15:04 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by sourceware.org (Postfix) with ESMTPS id B91A23858C5E for ; Wed, 16 Aug 2023 23:14:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B91A23858C5E 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-pg1-x542.google.com with SMTP id 41be03b00d2f7-564a0d2d35eso4256266a12.0 for ; Wed, 16 Aug 2023 16:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1692227676; x=1692832476; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8hsdKn/snGQKyMTV5QJchg+pS3CifPZdoLRL1nIb8ck=; b=RqrnIkfSLW3ijH/uLW+KUe2q7kHTKdldTzB2KblQQKYVDuBRgOKYjYCYNsxt9lk3IG uVtbHzFDaGBkjebZHDD3K104YIDRQBqkxlfrjArR0oeXKSlCdAmMv8KOzbM9fn/rp8kK Etgx2ySSUvnDGOvJiIw6qz88lkxIhgFgtRS+pVpi93MmAprEpyBAWfoXixqggCcCgrmY WaetUQ9M7erwCCmU4HldS8YU1vwfsFYKq9Xtcuwuxfvln7Tz1wQhFECXDZtvd5zaqOE2 OpiB7p5Iv6SOQfzLlI8gLQtBxMWk4C9LC0u29iLz1YZ9hYq4UxzyqQrmLOiwpFd04OLg XRWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692227676; x=1692832476; 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=8hsdKn/snGQKyMTV5QJchg+pS3CifPZdoLRL1nIb8ck=; b=agmLEO0AJsImbrlx5QU5KzFntxZCD+FACzNZBeWYiASkiyh0YzVKCoJH4asamPe2SO l/QOf1/XUyPtL+g2mHajiP2HFmI6oCN46y1YmwuBfybH2v8/D6hPha9SsGJ71LvFfzqZ C8+ZZEJyUlEkM341/VwcS4JTm9OrdWayfOU1Rl5TtkHXhmGqkLbdAcgpBQGexUTWjwtX BxRZuzGG1lxw3qy0lcKHkfc1kCu9MOvqMiEQW25F2mwghkMAMPekRglEu5OVRFPEKUDi Hnr5TsqLVFrYXetw1VCBkhrSuucHLCbIvcWcKu2OWR4+ATdJoOKQvwAaSnOU1LpVRUna aSiQ== X-Gm-Message-State: AOJu0YxRf5qTS6RAAU6U3bKSH4MGg4OVgkj2LyV4XwnyILijsvEOo+V1 muVBdLoGWYrmRulZmVu175lD0aduAlj1Dm3wATVrxyPJ X-Received: by 2002:a17:90b:1a88:b0:268:dd0:3497 with SMTP id ng8-20020a17090b1a8800b002680dd03497mr2586212pjb.7.1692227676383; Wed, 16 Aug 2023 16:14:36 -0700 (PDT) Received: from patrick-ThinkPad-X1-Carbon-Gen-8.hq.rivosinc.com ([50.221.140.188]) by smtp.gmail.com with ESMTPSA id ft3-20020a17090b0f8300b0026833291740sm248772pjb.46.2023.08.16.16.14.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 16:14:36 -0700 (PDT) From: Patrick O'Neill To: gcc-patches@gcc.gnu.org Cc: wangfeng@eswincomputing.com, jeffreyalaw@gmail.com, gnu-toolchain@rivosinc.com, palmer@rivosinc.com, charlie@rivosinc.com, Patrick O'Neill Subject: [PATCH] RISC-V: Add rotate immediate regression test Date: Wed, 16 Aug 2023 16:14:03 -0700 Message-Id: <20230816231403.321156-1-patrick@rivosinc.com> X-Mailer: git-send-email 2.34.1 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: 1774429362245541074 X-GMAIL-MSGID: 1774429362245541074 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-04.c: Add half-register rotation cases. * gcc.target/riscv/zbb-rol-ror-05.c: Add half-register rotation case. 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 --- .../gcc.target/riscv/zbb-rol-ror-04.c | 20 +++++++++++++++++++ .../gcc.target/riscv/zbb-rol-ror-05.c | 10 ++++++++++ 2 files changed, 30 insertions(+) diff --git a/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-04.c b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-04.c index 7ef4c29dd5b..dcd7be874ab 100644 --- a/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-04.c +++ b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-04.c @@ -51,3 +51,23 @@ unsigned int foo5(unsigned int rs1, unsigned int rs2) { return (rs1 >> rs2) | (rs1 << (32 - rs2)); } + +/* +**foo6: +** rori a0,a0,32 +** ret +*/ +unsigned long foo6(unsigned long rotate) +{ + return (rotate << 32) | (rotate >> 32); +} + +/* +**foo7: +** roriw a0,a0,16 +** ret +*/ +unsigned int foo7(unsigned int rotate) +{ + return (rotate << 16) | (rotate >> 16); +} diff --git a/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-05.c b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-05.c index 2108ccc3e77..5ae1d4a92d9 100644 --- a/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-05.c +++ b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-05.c @@ -23,3 +23,13 @@ unsigned int foo2(unsigned int rs1) { return (rs1 << 10) | (rs1 >> 22); } + +/* +**foo3: +** rori a0,a0,16 +** ret +*/ +unsigned int foo3(unsigned int rs1) +{ + return (rs1 << 16) | (rs1 >> 16); +}