From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 1E3F23857C4C for ; Sat, 17 Sep 2022 06:09:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1E3F23857C4C 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 D336E348C3; Sat, 17 Sep 2022 06:09:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1663394975; 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=kXAnduz/ySwRK4Zh+IDI06PBD3ReeNjILBm3xmfG0jw=; b=S9InZ22VbWIPX0llYUPCX8wuxLHENqCtdgvWM7zuHXBYOt76hcbgwuXNixqdGdVa73DcZS HfnhfVKTLTzT9s+g7mXpHejL2hmWYftG5LcZF2hAUi5dhUp51UwTeAIUc+3/TGNw7VlNoq ixePBaxBuJHktd349Y/XWjkPwAJpQ+M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1663394975; 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=kXAnduz/ySwRK4Zh+IDI06PBD3ReeNjILBm3xmfG0jw=; b=oovvhwK3nSGUCraAo9BE9Ycuaqdokr7ePqiVnN5MnaLKBn7b2qMwMQ6r/MK36/kkyyBit6 OMxgqh43+it3QmDA== 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 B8CE9139F9; Sat, 17 Sep 2022 06:09:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id /eEYLZ9kJWO2ewAAMHmgww (envelope-from ); Sat, 17 Sep 2022 06:09:35 +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 recent regression in optimize_range_tests_cmp_bitwise [PR106958] Date: Sat, 17 Sep 2022 08:09:34 +0200 Message-Id: References: Cc: Jeff Law , gcc-patches@gcc.gnu.org In-Reply-To: To: Jakub Jelinek X-Mailer: iPhone Mail (19H12) X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,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 17.09.2022 um 08:03 schrieb Jakub Jelinek via Gcc-patches : >=20 > =EF=BB=BFHi! >=20 > As the following testcase reduced from glibc fmtmsg.c shows > (it doesn't ICE on x86_64/i686 unfortunately, but does on various other > arches), my last optimize_range_tests_cmp_bitwise change wasn't fully > correct. The intent was to let all pointer operands be cast to > pointer_sized_int_node first in addition to the other casts (to type1) > which are done for id >=3D l cases. > But one spot I've touched used always cast to type1 (note, the (b % 4) =3D= =3D 3 > case is impossible for pointer operands because that is for !TYPE_UNSIGNED= > operands and pointers are TYPE_UNSIGNED) and in the other spot the cast > would be done only for id >=3D l if not useless, but for pointers we need > to cast it always. >=20 > The following patch fixes that, bootstrapped/regtested on x86_64-linux and= > i686-linux, ok for trunk? Ok. Richard=20 > 2022-09-17 Jakub Jelinek >=20 > PR tree-optimization/106958 > * tree-ssa-reassoc.cc (optimize_range_tests_cmp_bitwise): If > id >=3D l, cast op to type1, otherwise to pointer_sized_int_node. > If type has pointer type, cast exp to pointer_sized_int_node > even when id < l. >=20 > * gcc.c-torture/compile/pr106958.c: New test. >=20 > --- gcc/tree-ssa-reassoc.cc.jj 2022-09-14 12:36:28.902351064 +0200 > +++ gcc/tree-ssa-reassoc.cc 2022-09-16 22:25:23.671110030 +0200 > @@ -3680,15 +3680,18 @@ optimize_range_tests_cmp_bitwise (enum t > if (id =3D=3D l || POINTER_TYPE_P (TREE_TYPE (op))) > { > code =3D (b % 4) =3D=3D 3 ? BIT_NOT_EXPR : NOP_EXPR; > - g =3D gimple_build_assign (make_ssa_name (type1), code, op); > + tree type3 =3D id >=3D l ? type1 : pointer_sized_int_node; > + g =3D gimple_build_assign (make_ssa_name (type3), code, op); > gimple_seq_add_stmt_without_update (&seq, g); > op =3D gimple_assign_lhs (g); > } > tree type =3D TREE_TYPE (r->exp); > tree exp =3D r->exp; > - if (id >=3D l && !useless_type_conversion_p (type1, type)) > + if (POINTER_TYPE_P (type) > + || (id >=3D l && !useless_type_conversion_p (type1, type))) > { > - g =3D gimple_build_assign (make_ssa_name (type1), NOP_EXPR, exp);= > + tree type3 =3D id >=3D l ? type1 : pointer_sized_int_node; > + g =3D gimple_build_assign (make_ssa_name (type3), NOP_EXPR, exp);= > gimple_seq_add_stmt_without_update (&seq, g); > exp =3D gimple_assign_lhs (g); > } > --- gcc/testsuite/gcc.c-torture/compile/pr106958.c.jj 2022-09-16 22:27:= 53.143079198 +0200 > +++ gcc/testsuite/gcc.c-torture/compile/pr106958.c 2022-09-16 22:27:25.= 196458901 +0200 > @@ -0,0 +1,13 @@ > +/* PR tree-optimization/106958 */ > + > +int a; > +void bar (int); > + > +void > +foo (char *x, char *y) > +{ > + int b =3D a !=3D 0; > + int c =3D x !=3D 0; > + int d =3D y !=3D 0; > + bar (b | c | d); > +} >=20 > Jakub >=20