Message ID | Y/CrHDbQpnIxKUFj@tucnak |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp314989wrn; Sat, 18 Feb 2023 02:41:22 -0800 (PST) X-Google-Smtp-Source: AK7set+p2SU1trNIl3sUnMxtgq7QgrZ4vuE556q9fEVulBrfgYfU3qjWdOuFkmGhETzXu+SehDbj X-Received: by 2002:a05:6402:12ca:b0:4ad:7204:6968 with SMTP id k10-20020a05640212ca00b004ad72046968mr6803777edx.32.1676716882082; Sat, 18 Feb 2023 02:41:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676716882; cv=none; d=google.com; s=arc-20160816; b=C5Z7U4pVnVZQowf6hmjoksPIo438lJtJmTAIq99C7ttFuIr7pg3r+QK+li3EdUX571 kDW/3+ud0mjz6f5xFXSKYn4z4yDu0xzhTe2iHJcx51elikGMlZvc6buE945b5F7x7mUA pJhw9w63q/rcTouC+XMUYGS33NTFmxtISgQhlI6fmCDl12uRSVWksxtE9A88LRAhSKX8 l0M8Gzcu3ET7Cln0zZEse5p+JzNKzoP94NEDbBYog94cmsAInd5q61YSJ3jLIkiWBYck MWQQ8MwONYO7g8iUgLPmrE26KxOgv4omPL2Ohoy+sLUkZIcVThbt4e0zyDY6FdIIMxxS dIZA== 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-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=/4JthOrib5mlWq1givrF0T+sBk4d1KGNfnNn4nqhfeo=; b=TJo+0Dy6L1ACuLEXAnDLLlUUgrpa5HUgZFumoKdwjtjelI+jInb/iFnV6a8pRuLDpV q3vWGdDaPHtvdbR8C+CvoGl9WRSCKMsRGprCJVf+FdAO8BchdAvlal0a1Oz/6CVCQGEg GmpiNdaQ0VgyD3z2BZcMjNVPsA/qfxC+NqRQaS99w9eD5/Iy2RvJhFmJZXkWzi/4Je4y TN6j4HqdQeBYN8YGfNDkOxOQI2udezUz8c12tltoycDXaqf+dQL/pYiAf1SrulHg8TLj Jmdv1pqFEVeKiyckZHp/CO6Whwt7HkweCu9yjEDPxvODMTDufkj9bu1TkUt+/YzcN4CA 7tdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="xV8hV3/r"; 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 r6-20020a056402034600b004acc25476e9si7889985edw.363.2023.02.18.02.41.21 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 02:41:22 -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=@gcc.gnu.org header.s=default header.b="xV8hV3/r"; 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 16A003857B98 for <ouuuleilei@gmail.com>; Sat, 18 Feb 2023 10:41:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 16A003857B98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676716881; bh=/4JthOrib5mlWq1givrF0T+sBk4d1KGNfnNn4nqhfeo=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=xV8hV3/riPmsJWISY9wReqi2Kp4TsuVfmG3H78SBojqhd2fzasrmJnM4ehfII09Ya YyOL6fTPpo3ZrVv5xfqkj8mwA3x4IvGYtFdVf4YssaCh7bPYxw9ueHwWPeJYQ+NLtC Bf4/kcxpYDEjwjCwQy+7zKzLTk7GMfWjaUg0uUKM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 2F3F03858D32 for <gcc-patches@gcc.gnu.org>; Sat, 18 Feb 2023 10:40:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2F3F03858D32 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-317-JqAxMvxDPTeMxxDv2AI4tw-1; Sat, 18 Feb 2023 05:40:34 -0500 X-MC-Unique: JqAxMvxDPTeMxxDv2AI4tw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C30D9101A521; Sat, 18 Feb 2023 10:40:33 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.211]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 88FC74014D1E; Sat, 18 Feb 2023 10:40:33 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 31IAeUOX1771638 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 18 Feb 2023 11:40:30 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 31IAeTu31771637; Sat, 18 Feb 2023 11:40:29 +0100 Date: Sat, 18 Feb 2023 11:40:28 +0100 To: Richard Biener <rguenther@suse.de> Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] reassoc: Fold some statements [PR108819] Message-ID: <Y/CrHDbQpnIxKUFj@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Jakub Jelinek <jakub@redhat.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758165081472577641?= X-GMAIL-MSGID: =?utf-8?q?1758165081472577641?= |
Series |
reassoc: Fold some statements [PR108819]
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Jakub Jelinek
Feb. 18, 2023, 10:40 a.m. UTC
Hi! This spot in update_ops can replace one or both of the assign operands with constants, creating 1 & 1 and similar expressions which can confuse later passes until they are folded. Rather than folding both constants by hand and also handling swapping of operands for commutative ops if the first one is constant and second one is not, the following patch just uses fold_stmt_inplace to do that. I think we shouldn't fold more than the single statement because that could screw up the rest of the pass, we'd have to mark all those with uids, visited and the like. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-02-18 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/108819 * tree-ssa-reassoc.cc (update_ops): Fold new stmt in place. * gcc.dg/pr108819.c: New test. Jakub
Comments
> Am 18.02.2023 um 11:41 schrieb Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org>: > > Hi! > > This spot in update_ops can replace one or both of the assign operands with > constants, creating 1 & 1 and similar expressions which can confuse later > passes until they are folded. Rather than folding both constants by hand > and also handling swapping of operands for commutative ops if the first one > is constant and second one is not, the following patch just uses > fold_stmt_inplace to do that. I think we shouldn't fold more than the > single statement because that could screw up the rest of the pass, we'd have > to mark all those with uids, visited and the like. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Ok Richard > 2023-02-18 Jakub Jelinek <jakub@redhat.com> > > PR tree-optimization/108819 > * tree-ssa-reassoc.cc (update_ops): Fold new stmt in place. > > * gcc.dg/pr108819.c: New test. > > --- gcc/tree-ssa-reassoc.cc.jj 2023-02-16 10:41:11.000000000 +0100 > +++ gcc/tree-ssa-reassoc.cc 2023-02-17 22:43:18.949984553 +0100 > @@ -4687,6 +4687,9 @@ update_ops (tree var, enum tree_code cod > gimple_set_uid (g, gimple_uid (stmt)); > gimple_set_visited (g, true); > gsi_insert_before (&gsi, g, GSI_SAME_STMT); > + gimple_stmt_iterator gsi2 = gsi_for_stmt (g); > + if (fold_stmt_inplace (&gsi2)) > + update_stmt (g); > } > return var; > } > --- gcc/testsuite/gcc.dg/pr108819.c.jj 2023-02-17 17:50:10.084914418 +0100 > +++ gcc/testsuite/gcc.dg/pr108819.c 2023-02-17 17:48:30.765369964 +0100 > @@ -0,0 +1,19 @@ > +/* PR tree-optimization/108819 */ > +/* { dg-do compile } */ > +/* { dg-options "-O1 -fno-tree-ccp -fno-tree-forwprop" } */ > + > +int a, b; > + > +int > +main () > +{ > + int d = 1; > + for (; b; b++) > + if (a < 1) > + while (d <= a && a <= 0UL) > + { > + int *e = &d; > + *e = 0; > + } > + return 0; > +} > > Jakub >
--- gcc/tree-ssa-reassoc.cc.jj 2023-02-16 10:41:11.000000000 +0100 +++ gcc/tree-ssa-reassoc.cc 2023-02-17 22:43:18.949984553 +0100 @@ -4687,6 +4687,9 @@ update_ops (tree var, enum tree_code cod gimple_set_uid (g, gimple_uid (stmt)); gimple_set_visited (g, true); gsi_insert_before (&gsi, g, GSI_SAME_STMT); + gimple_stmt_iterator gsi2 = gsi_for_stmt (g); + if (fold_stmt_inplace (&gsi2)) + update_stmt (g); } return var; } --- gcc/testsuite/gcc.dg/pr108819.c.jj 2023-02-17 17:50:10.084914418 +0100 +++ gcc/testsuite/gcc.dg/pr108819.c 2023-02-17 17:48:30.765369964 +0100 @@ -0,0 +1,19 @@ +/* PR tree-optimization/108819 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-tree-ccp -fno-tree-forwprop" } */ + +int a, b; + +int +main () +{ + int d = 1; + for (; b; b++) + if (a < 1) + while (d <= a && a <= 0UL) + { + int *e = &d; + *e = 0; + } + return 0; +}