From patchwork Fri Jan 21 09:22:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiufu Guo X-Patchwork-Id: 50300 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 069023857C73 for ; Fri, 21 Jan 2022 09:22:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 069023857C73 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1642756968; bh=KPjOsSZlfwOKYdddcUu3jGl4REG6++E892YnXlqmSbI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=MYFP4ZqbirFy2+4rpClfyCkIZVh+HNCep2Ja9Ht57rMeRDZnLPugSd9QHqA77tvCZ cs2oFi+ALtypyuaImDsrBVWCiC9SV3ixku4jRR15id8xW87dbOWptA279joPhYOcKH 9vAONk0aNbooofc4pv0I29Vh9BwYyxVX0Mi13hUA= 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 2A8CB3858D37 for ; Fri, 21 Jan 2022 09:22:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2A8CB3858D37 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20L9HHQm009433; Fri, 21 Jan 2022 09:22:17 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3dqt2pg1qu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jan 2022 09:22:16 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 20L9I5v6010966; Fri, 21 Jan 2022 09:22:16 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 3dqt2pg1q6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jan 2022 09:22:16 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 20L9CXnL024086; Fri, 21 Jan 2022 09:22:14 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma05fra.de.ibm.com with ESMTP id 3dqjepjs55-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jan 2022 09:22:13 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 20L9MAfU46858722 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jan 2022 09:22:10 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7B0224C046; Fri, 21 Jan 2022 09:22:10 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3B17D4C052; Fri, 21 Jan 2022 09:22:09 +0000 (GMT) Received: from genoa.aus.stglabs.ibm.com (unknown [9.40.192.157]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 21 Jan 2022 09:22:09 +0000 (GMT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Update the type of control.base after changed Date: Fri, 21 Jan 2022 17:22:08 +0800 Message-Id: <20220121092208.3086415-1-guojiufu@linux.ibm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: H2WQf92rnxGLXZOmSclweOVwlyqsytXA X-Proofpoint-ORIG-GUID: Gm_TrprMzpi6ic22NWAKNEx9RWR9hkx9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-21_06,2022-01-20_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 suspectscore=0 adultscore=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 clxscore=1015 spamscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201210060 X-Spam-Status: No, score=-11.2 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Jiufu Guo via Gcc-patches From: Jiufu Guo Reply-To: Jiufu Guo Cc: rguenther@suse.de, segher@kernel.crashing.org, wschmidt@linux.ibm.com, jlaw@tachyum.com, dje.gcc@gmail.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi, This patch correct the type of niter->control.base, when it is updated as a PLUS expr. During build PLUS expr, the result type should align with the type of the operands. Bootstrap and regtest pass on ppc64/ppc64le and x86. Is this ok for trunk? BR, Jiufu PR tree-optimization/102087 gcc/ChangeLog: * tree-ssa-loop-niter.c (number_of_iterations_until_wrap): Correct PLUS result type. gcc/testsuite/ChangeLog: * gcc.dg/pr102087_1.c: New test. --- gcc/tree-ssa-loop-niter.c | 17 +++++++++++++++-- gcc/testsuite/gcc.dg/pr102087_1.c | 13 +++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr102087_1.c diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index b767056aeb0..21cc257c91b 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -1579,8 +1579,21 @@ number_of_iterations_until_wrap (class loop *loop, tree type, affine_iv *iv0, { IVbase - STEP, +, STEP } != bound Here, biasing IVbase by 1 step makes 'bound' be the value before wrap. */ - niter->control.base = fold_build2 (MINUS_EXPR, niter_type, - niter->control.base, niter->control.step); + tree base_type = TREE_TYPE (niter->control.base); + if (POINTER_TYPE_P (base_type)) + { + tree utype = unsigned_type_for (base_type); + niter->control.base + = fold_build2 (MINUS_EXPR, utype, + fold_convert (utype, niter->control.base), + fold_convert (utype, niter->control.step)); + niter->control.base = fold_convert (base_type, niter->control.base); + } + else + niter->control.base + = fold_build2 (MINUS_EXPR, base_type, niter->control.base, + niter->control.step); + span = fold_build2 (MULT_EXPR, niter_type, niter->niter, fold_convert (niter_type, niter->control.step)); niter->bound = fold_build2 (PLUS_EXPR, niter_type, span, diff --git a/gcc/testsuite/gcc.dg/pr102087_1.c b/gcc/testsuite/gcc.dg/pr102087_1.c new file mode 100644 index 00000000000..ba4efe3b412 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr102087_1.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/102087 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fprefetch-loop-arrays -w" { target x86_64-*-* powerpc*-*-* } } */ + +char **Gif_ClipImage_gfi_0; +int Gif_ClipImage_gfi_1, Gif_ClipImage_y, Gif_ClipImage_shift; +void Gif_ClipImage() { + Gif_ClipImage_y = Gif_ClipImage_gfi_1 - 1; + for (; Gif_ClipImage_y >= Gif_ClipImage_shift; Gif_ClipImage_y++) + Gif_ClipImage_gfi_0[Gif_ClipImage_shift] = + Gif_ClipImage_gfi_0[Gif_ClipImage_y]; +} +