From patchwork Sat Aug 20 17:14:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 640 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f406:0:0:0:0:0 with SMTP id g6csp290293wro; Sat, 20 Aug 2022 10:15:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR4urw7Py3sTTkIMjaOEi75lUGLiWFkB5noI9nyloyqPVcJvnv7kEj1pkGGfVy0rueyBYzU+ X-Received: by 2002:a05:6402:5488:b0:443:39c5:5347 with SMTP id fg8-20020a056402548800b0044339c55347mr10121357edb.204.1661015750888; Sat, 20 Aug 2022 10:15:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661015750; cv=none; d=google.com; s=arc-20160816; b=tAVj6Gx+KAg/yU6+F9RF43pfciYhcr7bI79ocgBMU05YoiRAgz3KiUuPuaEMsXv4RN vBW42kbDVOvHq4VNJpVjsAqm3hn3L/n/HGTABMaC+Q7hfUs4pUVkDOZ6z5wAqqMXDvsx KGN4TCewCRGAoOgk1IHB8+4bXJFvVZCOPCfrF96WIwtU1zWT5JiB2VU3fddFrj9QbY/c /I5S2wB6CGoXb4Yy8n75M7Pi//cvJXTXvWamEVPCMnatLMk/9wxOl1QadzNccuAfI6Jw jUNKFabKXwdj2ntsQ2mJEjDa3/s42qWOSCMv5P3AR0IBQD/X19qgI2j/EYIMIwSd4inp +8Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:references:in-reply-to:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=LSX6Fm4LyVTIqLL6WAPtkDWcBet6L9jG0hBKER1QAyw=; b=w/gr+dZpz2uuJBJbTN/jyxZMJM2k/G8ilI9ERkWy9sVkiVbAr6pxug/6nqeOIACbWB QCGIf8yA2q8y7JT7hiNNQbBmsfuWHVaerkBxY1mhMzBQMK5S8G14W124TSPYIcz7F0UU 7ExW8MjyTVbRUSjsLk68udxb4Ri+b5EO5bVQNs0HQ/YearHdagIQAe48ycrNB8wNhpTD bNRG70PGqflA82yM+JWAgoznF62jHxufOOYbuCrzsL4WQqgg3u0O6QS9PwtHFcIw75Mz Cpkntl/Ve2s77ySsut2yiGoRfb9EZybqbTdtPFlywOx31jE1515nrBobtN2mup8OxPWo PIkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gf8zkcbB; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id 5-20020a508e05000000b004458d44003csi5405412edw.499.2022.08.20.10.15.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Aug 2022 10:15:50 -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=@gcc.gnu.org header.s=default header.b=gf8zkcbB; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 489993857B89 for ; Sat, 20 Aug 2022 17:15:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 489993857B89 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661015722; bh=LSX6Fm4LyVTIqLL6WAPtkDWcBet6L9jG0hBKER1QAyw=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=gf8zkcbBIDvla3LVx6hLRkpw+8bb5OcQkEPzLap21zKEsP+Ks5tBGbh+3z4bcBxFb Gmo1kN4LcT615/zvz7nuTvn9YLFAHkEqDXg8PqfL5U9XsniWYEvuh7R0ROZmRM6B/7 k6BR7/iiLU/Q8yT5mjya2XMFDwQkepRlY52OMY5s= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by sourceware.org (Postfix) with ESMTPS id EE2B33858C52 for ; Sat, 20 Aug 2022 17:14:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EE2B33858C52 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27KFl5L4006946 for ; Sat, 20 Aug 2022 10:14:33 -0700 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3j2x2x0rb0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Sat, 20 Aug 2022 10:14:33 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 20 Aug 2022 10:14:32 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 20 Aug 2022 10:14:32 -0700 Received: from linux.wrightpinski.org.com (unknown [10.69.242.198]) by maili.marvell.com (Postfix) with ESMTP id 084963F7065; Sat, 20 Aug 2022 10:14:31 -0700 (PDT) To: Subject: [PATCH 1/3] Fix PR 106600: __builtin_bswap32 is not hooked up for ZBB for 32bit Date: Sat, 20 Aug 2022 10:14:24 -0700 Message-ID: <1661015666-14659-2-git-send-email-apinski@marvell.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1661015666-14659-1-git-send-email-apinski@marvell.com> References: <1661015666-14659-1-git-send-email-apinski@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: XsjRiwCE7rE50cHXVpcpu9MGGddryHYF X-Proofpoint-ORIG-GUID: XsjRiwCE7rE50cHXVpcpu9MGGddryHYF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-20_08,2022-08-18_01,2022-06-22_01 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: , X-Patchwork-Original-From: apinski--- via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: apinski@marvell.com Cc: Andrew Pinski 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?1741701252026918873?= X-GMAIL-MSGID: =?utf-8?q?1741701252026918873?= From: Andrew Pinski The problem here is the bswap2 pattern had a check for TARGET_64BIT but then used the X iterator. Since the X iterator is either SI or DI depending on the setting TARGET_64BIT, there is no reason for the TARGET_64BIT. OK? Built and tested on both riscv32-linux-gnu and riscv64-linux-gnu. Thanks, Andrew Pinski gcc/ChangeLog: PR target/106600 * config/riscv/bitmanip.md (bswap2): Remove condition on TARGET_64BIT as X is already conditional there. gcc/testsuite/ChangeLog: PR target/106600 * gcc.target/riscv/zbb_32_bswap-1.c: New test. * gcc.target/riscv/zbb_bswap-1.c: New test. Change-Id: Iba3187e5620b0f291f7c38aab597f367b47a22c5 --- gcc/config/riscv/bitmanip.md | 2 +- gcc/testsuite/gcc.target/riscv/zbb_32_bswap-1.c | 11 +++++++++++ gcc/testsuite/gcc.target/riscv/zbb_bswap-1.c | 11 +++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/riscv/zbb_32_bswap-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/zbb_bswap-1.c diff --git a/gcc/config/riscv/bitmanip.md b/gcc/config/riscv/bitmanip.md index d1570ce8508..c7ba667f87a 100644 --- a/gcc/config/riscv/bitmanip.md +++ b/gcc/config/riscv/bitmanip.md @@ -272,7 +272,7 @@ (define_insn "rotlsi3_sext" (define_insn "bswap2" [(set (match_operand:X 0 "register_operand" "=r") (bswap:X (match_operand:X 1 "register_operand" "r")))] - "TARGET_64BIT && TARGET_ZBB" + "TARGET_ZBB" "rev8\t%0,%1" [(set_attr "type" "bitmanip")]) diff --git a/gcc/testsuite/gcc.target/riscv/zbb_32_bswap-1.c b/gcc/testsuite/gcc.target/riscv/zbb_32_bswap-1.c new file mode 100644 index 00000000000..3ff7d9de409 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/zbb_32_bswap-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gc_zbb -mabi=ilp32" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } } */ + +int foo(int n) +{ + return __builtin_bswap32(n); +} + +/* { dg-final { scan-assembler "rev8" } } */ + diff --git a/gcc/testsuite/gcc.target/riscv/zbb_bswap-1.c b/gcc/testsuite/gcc.target/riscv/zbb_bswap-1.c new file mode 100644 index 00000000000..20feded0df2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/zbb_bswap-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_zbb -mabi=lp64" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } } */ + +int foo(int n) +{ + return __builtin_bswap32(n); +} + +/* { dg-final { scan-assembler "rev8" } } */ +