From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 3DAFC385841D for ; Wed, 12 Apr 2023 14:51:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3DAFC385841D 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-out2.suse.de (Postfix) with ESMTPS id 526DD1F6E6; Wed, 12 Apr 2023 14:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1681311070; 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=lULSzuQE/h/iq3WK5remAKbKLPj/Tdef71RIQROlOKk=; b=hcSSZpRjVb3gjhYBFhA+wFmu/zFO/Pn0pcS8HI1Is5TStdYP2wJ8UGUVUInMp3uw7ZtPRT FoAG/e2Bn1+Am4H0Mh10RyXeviMc8AxYPyy7OPqBOEfYsc521JDgCnJEZNXkTZXONpnW80 GCi/nHd6aX/WtAfAI5F06BR7EtqHJrk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1681311070; 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=lULSzuQE/h/iq3WK5remAKbKLPj/Tdef71RIQROlOKk=; b=D36NC9v8TT9UZ8VQ3kSGt9idpLrSsxhdFIZOVGf7eAjIgLdfGFUPwEJgo+Ug/XefbLTSEF /mbylg2eREMNHrBA== 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 459D8132C7; Wed, 12 Apr 2023 14:51:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id /dH4EF7FNmQDIwAAMHmgww (envelope-from ); Wed, 12 Apr 2023 14:51:10 +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: Fix up another ICE with returns_twice call [PR109410] Date: Wed, 12 Apr 2023 16:50:59 +0200 Message-Id: <96C02F62-DF5C-49B6-AF5F-4B7F5A55B1A4@suse.de> References: Cc: gcc-patches@gcc.gnu.org In-Reply-To: To: Jakub Jelinek X-Mailer: iPhone Mail (20E252) 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 12.04.2023 um 16:37 schrieb Jakub Jelinek via Gcc-patches : >=20 > =EF=BB=BFHi! >=20 > The following testcase ICEs in reassoc, unlike the last case I've fixed > there here SSA_NAME_USED_IN_ABNORMAL_PHI is not the case anywhere. > build_and_add_sum places new statements after the later appearing definiti= on > of an operand but if both operands are default defs or constants, we place= > statement at the start of the function. >=20 > If the very first statement of a function is a call to returns_twice > function, this doesn't work though, because that call has to be the first > thing in its basic block, so the following patch splits the entry successo= r > edge such that the new statements are added into a different block from th= e > returns_twice call. >=20 > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Ok. > I think we should in stage1 reconsider such placements, I think it > unnecessarily enlarges the lifetime of the new lhs if its operand(s) > are used more than once in the function. Unless something sinks those > again. Would be nice to place it closer to the actual uses (or where > they will be placed). IStR there is code to do that in reassoc already. >=20 > 2023-04-12 Jakub Jelinek >=20 > PR tree-optimization/109410 > * tree-ssa-reassoc.cc (build_and_add_sum): Split edge from entry > block if first statement of the function is a call to returns_twice > function. >=20 > * gcc.dg/pr109410.c: New test. >=20 > --- gcc/tree-ssa-reassoc.cc.jj 2023-02-18 12:40:42.739131728 +0100 > +++ gcc/tree-ssa-reassoc.cc 2023-04-12 13:23:49.083979843 +0200 > @@ -1564,6 +1564,15 @@ build_and_add_sum (tree type, tree op1, > && (!op2def || gimple_nop_p (op2def))) > { > gsi =3D gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)= )); > + if (!gsi_end_p (gsi) > + && is_gimple_call (gsi_stmt (gsi)) > + && (gimple_call_flags (gsi_stmt (gsi)) & ECF_RETURNS_TWICE)) > + { > + /* Don't add statements before a returns_twice call at the start > + of a function. */ > + split_edge (single_succ_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun))); > + gsi =3D gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun= ))); > + } > if (gsi_end_p (gsi)) > { > gimple_stmt_iterator gsi2 > --- gcc/testsuite/gcc.dg/pr109410.c.jj 2023-04-12 13:42:41.759751843 +0= 200 > +++ gcc/testsuite/gcc.dg/pr109410.c 2023-04-12 13:42:27.249959585 +0200= > @@ -0,0 +1,19 @@ > +/* PR tree-optimization/109410 */ > +/* { dg-do compile } */ > +/* { dg-options "-O2" } */ > + > +__attribute__((returns_twice)) int baz (int, int); > + > +int > +bar (int x) > +{ > + return x; > +} > + > +int > +foo (int x, int y) > +{ > + baz (x, y); > + int a =3D bar (x); > + return y || a =3D=3D 42 || a > 42; > +} >=20 > Jakub >=20