From patchwork Fri Oct 6 07:45:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schulze Frielinghaus X-Patchwork-Id: 149145 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp152116vqo; Fri, 6 Oct 2023 00:48:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKvT/Q4Yt35TZNYUI32dlSxRXubQ/7jihyVSnqvVi4RavaM3cMKFKocfiaLTaPqyMQgRTg X-Received: by 2002:a17:906:cd1:b0:9b2:b119:4909 with SMTP id l17-20020a1709060cd100b009b2b1194909mr6100386ejh.75.1696578514825; Fri, 06 Oct 2023 00:48:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696578514; cv=none; d=google.com; s=arc-20160816; b=kQWB11K41ISJiQYSbjcvzneLHYLUvl9deJ3naWoLNB1JR85fA3ZpUFXhFjtq+LC8W2 sJ4PivxkNrCQhPRx9aDENYnrIy9mPrulaszESYqRgmd0nxfv+n9SKrB/+NB7LJb72xuF xjMt/B7xyorL/xPcTAfghxa8rRdS5yCTpE5BYxOIbVV9Iy0zDoDUMP3zNG34ljmozjM2 g5ctNeZoieu2/WmY0AH5NxG9JOuld8iP4GEupu6CBBFxXBDwxY0lP+9jNh6r87tfc8X+ xgFAm+DjUC8tz55qjg58D6NTRoD9oe1XTu5aWMpQsEFgK+FS+D/E+0eE5iwkE1Bfons1 cMRg== ARC-Message-Signature: i=1; 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 :dmarc-filter:delivered-to; bh=Q3WegOxsRKz9+4ii6FF6W5ciKI2KyWctis9XMVKRevc=; fh=a5JL8Wt5ar62icC2rdno2Pb7FMS39q3+U5nVhD/l4ws=; b=jnduhZDURHh/HJ53BCxalqLBZbb1K4Jfyo5TpWf+/oKpJAdPz0TUzWU3JABaYa3pMw JUkpXsTC3gHUDDE083ZIzCFSuxm7Mp79885hmd1y3tGOk1bq2I+Nfwta7lgRlYbbEcTc B6pdHFxQX5C06H3i5qHncfElm6B0j+IlPFREEcyhs7N3vcJqL3rQ+iZAn426F+XgzB9s LkEhkTnaVPkABmQrYAnoTYW1ezkxhXjiXtYRmse2/rLwGpFIfF+3A+d0Wx7j6FsC9D+D wXkWGFKPvPeBizyeV8lmMX0+kGvQ1l0dAReRhU78HLthyyESirf9XAWq4tsVirhyvRPw JrVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=FrmfKVqh; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id i13-20020a170906a28d00b0099367e9043dsi1472300ejz.870.2023.10.06.00.48.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 00:48:34 -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=@ibm.com header.s=pp1 header.b=FrmfKVqh; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A4884385697F for ; Fri, 6 Oct 2023 07:48:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id E64F83858C2F for ; Fri, 6 Oct 2023 07:47:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E64F83858C2F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3967lYST000999 for ; Fri, 6 Oct 2023 07:47:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=Q3WegOxsRKz9+4ii6FF6W5ciKI2KyWctis9XMVKRevc=; b=FrmfKVqhpGoE3gnuoy9EiM0r/Ud0xdtJQu9VmpviRCJbVenW9PajZm3a8jC3uCpAlhbf OFv9qS85YdrN18e6l0xfp7PRHwPhpqYK39PAwD7Ic872T0CquKo8U7hPdVhDG1GFiEbF t4+BhlQp5h2SSknHEtckS1pEcLSNfj1SRq6CXO7hH0N9tV0WgivA/kgDWV+jVwjcEgPr Vj9WfOpHDfNjUkFCtS8BfuCrJjbwky8QzAoLEC71lymAmE+HXW3qT5BJ73M//EWieOuw Y634OFfhrc1CcXFBF7AfxVbngrEisRc+RmlxaY31okwGD2X9NVIJ2O6kM4c9nlZhrD8B +g== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3tje5er041-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 06 Oct 2023 07:47:49 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3967Xrmj010892 for ; Fri, 6 Oct 2023 07:47:48 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3tf0q2w0sn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 06 Oct 2023 07:47:48 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3967lksY26935954 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 6 Oct 2023 07:47:46 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E98372005A; Fri, 6 Oct 2023 07:47:45 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CC8732004E; Fri, 6 Oct 2023 07:47:45 +0000 (GMT) Received: from a8345010.lnxne.boe (unknown [9.152.108.100]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTPS; Fri, 6 Oct 2023 07:47:45 +0000 (GMT) From: Stefan Schulze Frielinghaus To: gcc-patches@gcc.gnu.org Cc: Stefan Schulze Frielinghaus Subject: [PATCH] combine: Fix handling of unsigned constants Date: Fri, 6 Oct 2023 09:45:31 +0200 Message-ID: <20231006074530.465276-2-stefansf@linux.ibm.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: sS8sRJOzN0uVb_951hl5XscT5kKsN719 X-Proofpoint-ORIG-GUID: sS8sRJOzN0uVb_951hl5XscT5kKsN719 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-06_04,2023-10-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 suspectscore=0 phishscore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 mlxlogscore=477 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310060054 X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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.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: 1778991512782921035 X-GMAIL-MSGID: 1778991512782921035 If a CONST_INT represents an integer of a mode with fewer bits than in HOST_WIDE_INT, then the integer is sign extended. For those two optimizations touched by this patch, the integers of interest have only the most significant bit set w.r.t their mode, therefore, they were sign extended. Thus in order to get the integer of interest, we have to chop off the high bits. Bootstrapped and regtested on x64, powerpc64le, and s390. Ok for mainline? gcc/ChangeLog: * combine.cc (simplify_compare_const): Fix handling of unsigned constants. --- gcc/combine.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/combine.cc b/gcc/combine.cc index 468b7fde911..80c4ff0fbaf 100644 --- a/gcc/combine.cc +++ b/gcc/combine.cc @@ -11923,7 +11923,7 @@ simplify_compare_const (enum rtx_code code, machine_mode mode, /* (unsigned) < 0x80000000 is equivalent to >= 0. */ else if (is_a (mode, &int_mode) && GET_MODE_PRECISION (int_mode) - 1 < HOST_BITS_PER_WIDE_INT - && ((unsigned HOST_WIDE_INT) const_op + && (((unsigned HOST_WIDE_INT) const_op & GET_MODE_MASK (int_mode)) == HOST_WIDE_INT_1U << (GET_MODE_PRECISION (int_mode) - 1))) { const_op = 0; @@ -11962,7 +11962,7 @@ simplify_compare_const (enum rtx_code code, machine_mode mode, /* (unsigned) >= 0x80000000 is equivalent to < 0. */ else if (is_a (mode, &int_mode) && GET_MODE_PRECISION (int_mode) - 1 < HOST_BITS_PER_WIDE_INT - && ((unsigned HOST_WIDE_INT) const_op + && (((unsigned HOST_WIDE_INT) const_op & GET_MODE_MASK (int_mode)) == HOST_WIDE_INT_1U << (GET_MODE_PRECISION (int_mode) - 1))) { const_op = 0;