From patchwork Sun May 21 04:50:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 96828 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp701734vqo; Sat, 20 May 2023 21:51:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7YPRLvl6Ey8pxR6Jq3k7eYJTBMAfIDgXHwmm1MGOsRfgo+EjqeexWwHuJlSYGVxnXc3NI0 X-Received: by 2002:a17:907:9723:b0:94a:549c:4731 with SMTP id jg35-20020a170907972300b0094a549c4731mr6491971ejc.57.1684644662074; Sat, 20 May 2023 21:51:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684644662; cv=none; d=google.com; s=arc-20160816; b=ykLLcDCU2vGsJyG9XoeY+Vf33bSUoRRMt2JGx7UTQvxCzaScOHu1Uombyytj4aTzRW KJ8d8+3da0Z1bqgQyIq5HG4WLueI+VLfkqqFz0jznUXhY9VncJZNFDGPeCQqf7AI8VEw 8oZ2Le2oBZ/zIxHH8kwjQ3i5XPSVYv9fJ34QCDRCbFTgws8eAHGPb/CRgA/51L2v1a/s xU7Jo86IiWmGOA8+pRdJl3MwsrKac9GuzIrx6LCulBm37N61nSKndt5adiN4JI7k88Qt iAPyVQtIEXboo9g/t008DHgrPUfp6ONB+6BXVbmSnZvmpqWb0iE6DZO5+K439g2Vejsg qoCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=7f8za670kOMKqbWhuVCwTn5pJ7one+LDABq/doAxLeg=; b=ASX5gT3WG3iS+5NDdqQwyLXYIyfis6ZeH0yw2MFP+KgTOY7fA/0oOdnU5WX6VM/DVm K9jpj2BSBILDZMFxEv5gYs0JQpggXUomUnaUTtwHCel3YwNNiNf3w9Qine1jHa8apG8y BddMF6Bo6pKXmvEb4fHBjzxsnqGeSh4JYNGzLvQLffuQONBW87wCUvIxlnMhba0XcTbV z8Cc5D8QjjV5o0NBGvwINlrtAnJfnmH6fZmp7oXCe7YP79DlBQ1DMNAwrYRVXmJ7hHMl Z3TYB6bZRfyW9AlL/rv708cvGjvBFc9k1EG9mEpz4vYtZ0js66nQsxjk5fNWWTQWIZAW LLXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Rop2qFU3; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id c9-20020a170906694900b0096b1c38458dsi750342ejs.409.2023.05.20.21.51.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 May 2023 21:51:02 -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=@gcc.gnu.org header.s=default header.b=Rop2qFU3; 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"; 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 DC64E3858C31 for ; Sun, 21 May 2023 04:51:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC64E3858C31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684644660; bh=7f8za670kOMKqbWhuVCwTn5pJ7one+LDABq/doAxLeg=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Rop2qFU3s/OePbXrebJdKmFaKQo4J6etcgWz6Ls6q7dZdH3/XX4Jo3ZPjideMVNWC ioVW9wxFy9qW/PRxEbXvu0yqsMhoIVC93XAmemLxIfg7HvnpBuHWyGJaWbYPu3hpBi 5mMT4prh2uj17JM/YfnBmZpDtZkB5RbpzCfRiSZc= 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 6FCFB3858D20 for ; Sun, 21 May 2023 04:50:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6FCFB3858D20 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34L4mlbN027782 for ; Sat, 20 May 2023 21:50:16 -0700 Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3qpujna049-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Sat, 20 May 2023 21:50:16 -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.48; Sat, 20 May 2023 21:50:14 -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.48 via Frontend Transport; Sat, 20 May 2023 21:50:14 -0700 Received: from vpnclient.wrightpinski.org.com (unknown [10.69.242.187]) by maili.marvell.com (Postfix) with ESMTP id 68AE63F7470; Sat, 20 May 2023 21:50:14 -0700 (PDT) To: CC: Andrew Pinski Subject: [PATCH] Fix expand_single_bit_test for big-endian Date: Sat, 20 May 2023 21:50:07 -0700 Message-ID: <20230521045007.1966279-1-apinski@marvell.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: x-Ct97e48DkGbcWMyNTZo4Y_SB6NHerO X-Proofpoint-GUID: x-Ct97e48DkGbcWMyNTZo4Y_SB6NHerO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-21_02,2023-05-17_02,2023-02-09_01 X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, 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: Andrew Pinski via Gcc-patches From: Andrew Pinski Reply-To: 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?1766477960908106030?= X-GMAIL-MSGID: =?utf-8?q?1766477960908106030?= I had thought extract_bit_field bitpos argument was the shifted position and not the bitposition like BIT_FIELD_REF so I had removed the code which would use the correct bitposition for BYTES_BIG_ENDIAN. Committed as obvious; I checked big-endian MIPS to make sure we are now producing the correct code. gcc/ChangeLog: * expr.cc (expand_single_bit_test): Correct bitpos for big-endian. --- gcc/expr.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gcc/expr.cc b/gcc/expr.cc index 02f24c00148..050efcd0b00 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -12958,7 +12958,14 @@ expand_single_bit_test (location_t loc, enum tree_code code, rtx inner0 = expand_expr (inner, NULL_RTX, VOIDmode, EXPAND_NORMAL); - inner0 = extract_bit_field (inner0, 1, bitnum, 1, target, + int bitpos = bitnum; + + scalar_int_mode imode = as_a (GET_MODE (inner0)); + + if (BYTES_BIG_ENDIAN) + bitpos = GET_MODE_BITSIZE (imode) - 1 - bitpos; + + inner0 = extract_bit_field (inner0, 1, bitpos, 1, target, operand_mode, mode, 0, NULL); if (code == EQ_EXPR)