From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 84D533858D32 for ; Sat, 18 Feb 2023 11:21:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 84D533858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A4DB037221; Sat, 18 Feb 2023 11:21:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1676719274; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JxJ8wW8vjkDhm4MWIlwvU8no9CjowxnBpxAyR3BlJfQ=; b=T8SyeNyoKQCDhlMcQnLpAYLgxc/PoKS0SFUvFXq6LhLFj5srWm0H06p+dSF13QQbt0KJeN TU+KM7+8JdbQO0NTPczUpDhULhJY67x1cHRE2KwirtU119QNBge2HoPrXnCxi6uyp8yPhA fk1e0xnLtx0N9JPmoQ/nzsi3/Fup6rM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1676719274; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JxJ8wW8vjkDhm4MWIlwvU8no9CjowxnBpxAyR3BlJfQ=; b=q1jLVds0FmnfjXBgf99gem4endRRFrVNaxlV1pPF/gaTRgSpg5j8sz6g286aMHVVeimUNX H4e1mNKiybUIyYCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 93FB0134BA; Sat, 18 Feb 2023 11:21:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id K7wYJKq08GPAJwAAMHmgww (envelope-from ); Sat, 18 Feb 2023 11:21:14 +0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Richard Biener Mime-Version: 1.0 (1.0) Subject: Re: [PATCH] reassoc: Fold some statements [PR108819] Date: Sat, 18 Feb 2023 12:21:03 +0100 Message-Id: <66CCC6DC-1934-422E-9271-8D8592D6B243@suse.de> References: Cc: gcc-patches@gcc.gnu.org In-Reply-To: To: Jakub Jelinek X-Mailer: iPhone Mail (20D67) X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 List-Id: > Am 18.02.2023 um 11:41 schrieb Jakub Jelinek via Gcc-patches : >=20 > =EF=BB=BFHi! >=20 > This spot in update_ops can replace one or both of the assign operands wit= h > 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 on= e > 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 ha= ve > to mark all those with uids, visited and the like. >=20 > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Ok Richard=20 > 2023-02-18 Jakub Jelinek >=20 > PR tree-optimization/108819 > * tree-ssa-reassoc.cc (update_ops): Fold new stmt in place. >=20 > * gcc.dg/pr108819.c: New test. >=20 > --- 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 =3D 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 +0= 100 > +++ 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 =3D 1; > + for (; b; b++) > + if (a < 1) > + while (d <=3D a && a <=3D 0UL) > + { > + int *e =3D &d; > + *e =3D 0; > + } > + return 0; > +} >=20 > Jakub >=20