From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 67CF03858CDA for ; Tue, 2 Jul 2024 07:56:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 67CF03858CDA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 67CF03858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719906987; cv=none; b=DvWq9y5UAScS9aK9RExpHe/Bh/Axw1xc+aJwau1mL83jhvgU1ly+AmqU0oBmjja7D46R5q0pVzaqbKa1yIexykdvGst0iImg+QC3LGEIqxJfrLssjGIvJ+U/Lds0LrJ+lYBGPtUABfv4YDhVuBCkmyNP00EUeaQf+YTi/BBpTuY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719906987; c=relaxed/simple; bh=OQNTB196OoXXupt3nEfF0SQUzUr9qJ8KZHmq6CE2qd4=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:Message-ID:MIME-Version; b=eu0OklkIIsJ6KOpsppekmmy/WAcOK/GGveOKm+JOUOacK6COz5zytkMPDgfr17HEbStQwTtvTsHsWABVZLlEFGzdIkoJYsmeTzXll8mw4CNt5JZBJ4mADPxEuP9BKdXABsNK4OWS6PjAT4zmmec+e3G90pHUWCgRyphPobbD16g= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from murzim.nue2.suse.org (unknown [10.168.4.243]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5F30A21B13; Tue, 2 Jul 2024 07:56:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1719906984; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ECkbI4kGLT80m8Zan5bfMSBOJuLutLw5JDIJDREG9HM=; b=TdXylljNZqTZiiq5VLG5NZ2GWM6JsQnhvIEGuoz22uG+F8RpJ6BLLv1ew8pGEyYX5po5TW 3sYwa6m6mc5Lle/bPYzQoZro5XRWwbXmGcFmZjm0hn1OewPWbNoDdB+pYrbCJRiGNga5lf 2j3G7xdvdckeVYfqXfTdPTb3VfGuCuk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1719906984; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ECkbI4kGLT80m8Zan5bfMSBOJuLutLw5JDIJDREG9HM=; b=P2/iU4qVNIfK5fakOYIjlK5jZ4KBQzTXVr5chE4SUvJE3thNjUy8+JXXXiLxGYjZjaOxvv z5AmJENsRe7WiSAQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1719906984; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ECkbI4kGLT80m8Zan5bfMSBOJuLutLw5JDIJDREG9HM=; b=TdXylljNZqTZiiq5VLG5NZ2GWM6JsQnhvIEGuoz22uG+F8RpJ6BLLv1ew8pGEyYX5po5TW 3sYwa6m6mc5Lle/bPYzQoZro5XRWwbXmGcFmZjm0hn1OewPWbNoDdB+pYrbCJRiGNga5lf 2j3G7xdvdckeVYfqXfTdPTb3VfGuCuk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1719906984; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ECkbI4kGLT80m8Zan5bfMSBOJuLutLw5JDIJDREG9HM=; b=P2/iU4qVNIfK5fakOYIjlK5jZ4KBQzTXVr5chE4SUvJE3thNjUy8+JXXXiLxGYjZjaOxvv z5AmJENsRe7WiSAQ== Date: Tue, 2 Jul 2024 09:56:24 +0200 (CEST) From: Richard Biener To: Tamar Christina cc: gcc-patches@gcc.gnu.org, nd@arm.com, jlaw@ventanamicro.com Subject: Re: [PATCH 1/2]middle-end: fix wide_int_constant_multiple_p when VAL and DIV are 0. [PR114932] In-Reply-To: Message-ID: <2n809s0q-8o09-9q03-01qn-58693r770n1n@fhfr.qr> References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-0.993]; MIME_GOOD(-0.10)[text/plain]; MISSING_XM_UA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email] X-Spam-Score: -4.30 X-Spam-Level: X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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: On Mon, 1 Jul 2024, Tamar Christina wrote: > Hi All, > > wide_int_constant_multiple_p tries to check if for two tree expressions a and b > that there is a multiplier which makes a == b * c. > > This code however seems to think that there's no c where a=0 and b=0 are equal > which is of course wrong. > > This fixes it and also fixes the comment. > > Bootstrapped Regtested on aarch64-none-linux-gnu, > x86_64-pc-linux-gnu -m32, -m64 and no issues. > > Ok for master? > > Thanks, > Tamar > > gcc/ChangeLog: > > PR tree-optimization/114932 > * tree-affine.cc (wide_int_constant_multiple_p): Support 0 and 0 being > multiples. > > --- > diff --git a/gcc/tree-affine.cc b/gcc/tree-affine.cc > index d6309c4390362b680f0aa97a41fac3281ade66fd..bfea0fe826a6affa0ace154e3ca38c9ef632fcba 100644 > --- a/gcc/tree-affine.cc > +++ b/gcc/tree-affine.cc > @@ -880,11 +880,10 @@ free_affine_expand_cache (hash_map **cache) > *cache = NULL; > } > > -/* If VAL != CST * DIV for any constant CST, returns false. > - Otherwise, if *MULT_SET is true, additionally compares CST and MULT, > - and if they are different, returns false. Finally, if neither of these > - two cases occur, true is returned, and CST is stored to MULT and MULT_SET > - is set to true. */ > +/* If VAL == CST * DIV for any constant CST, returns true. > + and if *MULT_SET is true, additionally compares CST and MULT > + and if they are different, returns false. If true is returned, CST is > + stored to MULT and MULT_SET is set to true. */ > > static bool > wide_int_constant_multiple_p (const poly_widest_int &val, > @@ -895,6 +894,12 @@ wide_int_constant_multiple_p (const poly_widest_int &val, > > if (known_eq (val, 0)) > { > + if (maybe_eq (div, 0)) shouldn't that be known_eq as well? > + { > + *mult = 1; and this looks wrong - it shouldn't update *mult if already set, *mult could be 4 (constrained by other sub-expressions). I think it also shouldn't set *mult_set to true. The function comment should mention this exceptional case 0 == CST * O, maybe as "If VAL and DIV are zero then any constant CST satisfies the equality. In this case neither *MUL nor *MULT_SET are updated and the function returns true." OK with that changes. Richard. > + return true; > + } > + > if (*mult_set && maybe_ne (*mult, 0)) > return false; > *mult_set = true; > > > > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)