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 B9BA43858CDA for ; Tue, 2 Jul 2024 08:01:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B9BA43858CDA 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 B9BA43858CDA 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=1719907278; cv=none; b=mYQ69zX44jziOcY4X1m3tJQWjM3Cm98JwYO03MHlxvuzkrOJ5otfOIS/iJD/Qvjn+PP/cWhsHWrL6MkH/IjwwkM5f+2FjxnaNoIN4/Xb4brOllJark67ZcxFfUbPJX5wSSo64W/bqntXpmxz6kfHW9EPXr8NE6HIrssZ5Oq2SFQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719907278; c=relaxed/simple; bh=BBVW0Vmdvvq6m7hGBiepkbxSPiUlAp7LUtqN/H+BQ7M=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:Message-ID:MIME-Version; b=jA8Pv5kGsEdO3SKVmEtO4Qd1CpEK8EbyHjSG5CyITRqVSCBRG6y2iioToV2RfmtNyI4h4O/NnOKRSqN1CITaOO+KTgiD3O24tY1UgAfVl7zHnGDRYQo+yICmtRaZyz2UL2xgYQ9VG471/i8aR4HlDnrcLjz2Yp31b802Bb5OwJY= 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 A540B21B1A; Tue, 2 Jul 2024 08:01:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1719907273; 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=vLWRGHRXOUzr1hGPaVg7yO9yDszSYAFo5gE9AxqNyy4=; b=Fq/EkMTD/ilV9B4JQaLUDMdVUHkNBAxjyJe2TGk9CBvT4DlVTX8hIoXNUCLqpxXIBFrczu Z32Be/0jx4VXvbmEXYZHv/AVLRgp8qenukzY5KuYJI3jie2RMB/4+etiDWbb4YRgaTahPL hxZCGtY6kyyfLMi2CZjLQkqpxr62Snw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1719907273; 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=vLWRGHRXOUzr1hGPaVg7yO9yDszSYAFo5gE9AxqNyy4=; b=cvJq4F2fBh0pBQuUd60QEWgW+E0ge4nYrZ0VCJoDXe00zbSd7BKJVGdtGQeuXO7pg0an+0 T3E2lpEUOdf6LJCQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1719907273; 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=vLWRGHRXOUzr1hGPaVg7yO9yDszSYAFo5gE9AxqNyy4=; b=Fq/EkMTD/ilV9B4JQaLUDMdVUHkNBAxjyJe2TGk9CBvT4DlVTX8hIoXNUCLqpxXIBFrczu Z32Be/0jx4VXvbmEXYZHv/AVLRgp8qenukzY5KuYJI3jie2RMB/4+etiDWbb4YRgaTahPL hxZCGtY6kyyfLMi2CZjLQkqpxr62Snw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1719907273; 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=vLWRGHRXOUzr1hGPaVg7yO9yDszSYAFo5gE9AxqNyy4=; b=cvJq4F2fBh0pBQuUd60QEWgW+E0ge4nYrZ0VCJoDXe00zbSd7BKJVGdtGQeuXO7pg0an+0 T3E2lpEUOdf6LJCQ== Date: Tue, 2 Jul 2024 10:01:13 +0200 (CEST) From: Richard Biener To: Tamar Christina cc: "gcc-patches@gcc.gnu.org" , nd , "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: 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]; FROM_HAS_DN(0.00)[]; MISSING_XM_UA(0.00)[]; TO_DN_SOME(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; 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)[tree-affine.cc:url,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: > > -----Original Message----- > > From: Tamar Christina > > Sent: Monday, July 1, 2024 9:14 PM > > To: gcc-patches@gcc.gnu.org > > Cc: nd ; rguenther@suse.de; jlaw@ventanamicro.com > > Subject: [PATCH 1/2]middle-end: fix wide_int_constant_multiple_p when VAL and > > DIV are 0. [PR114932] > > > > 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..bfea0fe826a6affa0ace154e3ca > > 38c9ef632fcba 100644 > > --- a/gcc/tree-affine.cc > > +++ b/gcc/tree-affine.cc > > @@ -880,11 +880,10 @@ free_affine_expand_cache (hash_map > name_expansion *> **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)) > > + { > > + *mult = 1; > > + return true; > > + } > > + > > Note, I also tested known_eq here, and also no regression on what I can test. > I picked maybe_eq since that's what the lines after this one tests. I think the maybe_eq (div, 0) is because otherwise multiple_p might crash? I'm not sure if there's a difference between maybe_eq (x, 0) and known_eq (x, 0) though - how does a maybe_eq POLY_INT look like that's not known_eq? > I'm not sure I fully understand why one tests known and the other maybe. It seems to me > that both should test known. But I tested both so which ever one is felt to be more correct > I can commit If ok. > > Thanks, > Tamar > > > 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)