From patchwork Fri Jan 26 05:02:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Andrew Pinski (QUIC)" X-Patchwork-Id: 192410 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:e09d:b0:103:945f:af90 with SMTP id gm29csp450089dyb; Thu, 25 Jan 2024 21:03:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IHi8jIMDp3U471Hz8rBA36m8yl4ss87tAeWxtGHxWhPfSiyqBgsEP6YVbiHMrE4E1YcQT4Q X-Received: by 2002:a05:620a:ecc:b0:783:3b03:4a11 with SMTP id x12-20020a05620a0ecc00b007833b034a11mr848339qkm.119.1706245414364; Thu, 25 Jan 2024 21:03:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706245414; cv=pass; d=google.com; s=arc-20160816; b=bL8l9M7N8GhvLwqTRf4AVg/Khct6LvckoOcpZTuUlgHxXkTLwlKSg9rIiV2CBcQAse dN2DfS1fexpu8cdfEYq1rS6qUDFX8swyPeBfsMGc2qpwvd/W+d1D0kwSlF/M/NrQrBTU +iwFNUxbMkqVAaVw1UE7vqx/gkUiu+zCgfpfUFlU/fzcepkRE+ucvmjwjoNRoGkvzYFr c8IRFB8RBCaZEaxk7OVNvxfEZ1ZGyFHprBqAXFpHgiYOEzgfxYLoiUCN9hjVzUh4S0go 7QQU5IrVXG0l/0nJFt+9Q4Ziv30PmQcyw+gkQf8vjdseUmWyxAeO+mm7H0T3bsOXVI8V Bb7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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 :arc-filter:dmarc-filter:delivered-to; bh=0WDeTtzvhCwK2URXA47YY4x+W/+MnWgWBQjV6gazkLo=; fh=o3CEdS3yGN/eIa89Zn0Kf01WYLxTE9IjKuSQGVPeOHI=; b=CEdOseD/dvTlmvA4IBzn5g03yg+tNWFlIMmtCYtbLqDZ4Lin3ZzWpvebSzYnk9LyrZ W4xgKiiEo/KTAK3PvitJkDX6qrUjfuzcQkPCGkfn/yixDL9jyAiF1SGbXmxEHd3K3VUb QwFFhQsHEDPF3n411M1E3uGjFyTZGQGuaKaCUrYX0y/v7ADekoN/em+pN5nLRcaNrM/s uMhusRkBZfwq41CZv0JxMPwH+ktNaxp4wU2leac2BSi0gq8lyXlrgxf7k2i8eSZSMyfR 1RsBqCC8Yih3AfobIFWIakoA+XAYryzYJgUoGddnjhTzyf8b2KwL6fsKVYGDpLDX3Xka 75Gg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jGDo66eD; arc=pass (i=1); 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=quicinc.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n18-20020ae9c312000000b0078319e53b1csi538109qkg.412.2024.01.25.21.03.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 21:03:34 -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=@quicinc.com header.s=qcppdkim1 header.b=jGDo66eD; arc=pass (i=1); 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=quicinc.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F3B233858297 for ; Fri, 26 Jan 2024 05:03:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by sourceware.org (Postfix) with ESMTPS id 5D0D33858D38 for ; Fri, 26 Jan 2024 05:02:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5D0D33858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=quicinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5D0D33858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706245374; cv=none; b=gLRHRlT9brMjpWyaCC6gPjrCk+PYHd3RKWCm2k7EYt3yRtU9DWB6/Rcpx/TTQhwC2mIKaqY2e0HrE+CqHd9IYM1x+NXG6vH+ZNgm2VnO22cIyoKnLwOQlbqB6bPlKLNnvS7f8xfalIpSrASo/b2A1SsF90bHDCJIQNMZaRGdMjU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706245374; c=relaxed/simple; bh=brIIIvfu/twq+nJ8lPzmKbcYd/Y2CE1M6YQ1BJrfgpU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Uz5/1GQmKo0aBg977cBe/gTV9m3bOeTpspGHGEo9Q3NNsU1PuwImKXpdvfRGbOHZPXfZWwRuExIVNfeYT7cjqZa/HhaBP0l9FjSNRwhTHuQC6LWi05WLeqg/fPl/IH8diWKgpciWjqhGCkt//9eQqDypKs/5MjFODZF4Vj73z9M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40Q4A793028851 for ; Fri, 26 Jan 2024 05:02:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=qcppdkim1; bh=0WDeTtz vhCwK2URXA47YY4x+W/+MnWgWBQjV6gazkLo=; b=jGDo66eD4ifuO+WxkRIcVrM KMSfFo/7rg3HjP4kZ+p8I3Mlfcwu0ukEnak114D61ZDUnOUcKFemOW/8xtvUwc0W U1FIuFWDhOIHPTOhygzBkHLir4xdgXwLAjUh3JmBYkobmleAMEgQ6ZTN1s4Zf36c 23/cTUuaqtkrY+C8fUQJCG4nlklDbqq1pg8KHyl9uDVOeB5JgKtZaggca5cYCV9u 5b2blWC5j8765rflrFYm2Jsl74//fVraBVMqsNqh+Sn99n6KoD4zIIpMMl9suOnI FqNDKusnznbgFKYRGbWyRIwNVnRWOZqKhxA9eEzgbF/F39VygDiClC16zqcL/Gg= = Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vv4nr84xs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 26 Jan 2024 05:02:51 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 40Q52oWf026859 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 26 Jan 2024 05:02:50 GMT Received: from hu-apinski-lv.qualcomm.com (10.49.16.6) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 25 Jan 2024 21:02:50 -0800 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH] aarch64: Fix/avoid undefinedness in aarch64_classify_index [PR100212] Date: Thu, 25 Jan 2024 21:02:35 -0800 Message-ID: <20240126050235.608008-1-quic_apinski@quicinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: TWRsl6CHF5U33_7WvBVZaBTgysJ9Ji2t X-Proofpoint-GUID: TWRsl6CHF5U33_7WvBVZaBTgysJ9Ji2t X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-25_14,2024-01-25_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 mlxlogscore=907 spamscore=0 mlxscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401260034 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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.30 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789127991233172661 X-GMAIL-MSGID: 1789127991233172661 The problem here is we don't check the return value of exact_log2 and always use that result as shifter. This fixes the issue by avoiding the shift if the value was `-1` (which means the value was not exact a power of 2); in this case we could either check if the values was equal to -1 or not equal to because we then assign -1 to shift if the constant value was not equal. I chose `!=` as it seemed to be more obvious of what the code is doing. Committed as obvious after a build/test for aarch64-linux-gnu. gcc/ChangeLog: PR target/100212 * config/aarch64/aarch64.cc (aarch64_classify_index): Avoid undefined shift after the call to exact_log2. Signed-off-by: Andrew Pinski --- gcc/config/aarch64/aarch64.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index d2014ce1527..19c608bc3ed 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -10246,7 +10246,9 @@ aarch64_classify_index (struct aarch64_address_info *info, rtx x, type = ADDRESS_REG_UXTW; index = XEXP (XEXP (x, 0), 0); shift = exact_log2 (INTVAL (XEXP (XEXP (x, 0), 1))); - if (INTVAL (XEXP (x, 1)) != (HOST_WIDE_INT)0xffffffff << shift) + /* Avoid undefined code dealing with shift being -1. */ + if (shift != -1 + && INTVAL (XEXP (x, 1)) != (HOST_WIDE_INT)0xffffffff << shift) shift = -1; } /* (and:DI (ashift:DI (reg:DI) (const_int shift))