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 45A633858C50 for ; Tue, 2 Jul 2024 07:58:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 45A633858C50 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 45A633858C50 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=1719907091; cv=none; b=gVviguQmE20RI00hCaTwjYNspOwQPp0LE/lcNYnPaRd2moIz5axduUYoX4U66ALrTqWi/uQ6OBsenbQdQ80e/xg2jhd3oD9SMJdiTegqv+aeQ9uwwyEexhtO25BiycBT+oDU3rgNIXoW2OJ9RonzX5h1k1aAt2e7R775+61lMXE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719907091; c=relaxed/simple; bh=zIxJVo33y/CzEHOtFwBBq8exTc0PiNaTp6rpkNJWeQk=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:Message-ID:MIME-Version; b=gicFjiE4J+3DVYYf3mX23mHVuH1nUOFCl+/pJYfwJ7GW9ANLHUM1e08zb/ouUY++d0XaE3vGS8YDb8azSU/HTZf37SXhfG17HXvITKtjL+o4elVxe4F/hTTsGD7SzE+bJC8YWtDG4pau6vpR3PoWRviXiR6TawdLgmP2Oh4ZAjQ= 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 3972821AC6; Tue, 2 Jul 2024 07:58:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1719907088; 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=z2S2rdnedmkdXjn0P0IMykHc3f2pcar7VAdyqTU3RlE=; b=oYAOQ9f0T7fu3n1pXH5rlVE4WIciLNSm5uqNojpO9bqK5WN6tr/bNkJfL4Rg5nmmMrXpxz 0KMZv/FQ7KY8YT41YrfyRiNU+cW5af2lU8Pp65Sy2Tem4N5gNX2bk3WW3SehkIuNOsu5ku rCahzuyo7iqcbH8g2tZa+Ave/G3b8+4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1719907088; 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=z2S2rdnedmkdXjn0P0IMykHc3f2pcar7VAdyqTU3RlE=; b=SuatxsjBrHw1TThDRpQN07EIGtjjlt6xIiRvcY8mJ3fGID7J+Pgvt0/JwBTbTwf2uS0ez+ ZUvVJe6l4Ppma0BQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1719907088; 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=z2S2rdnedmkdXjn0P0IMykHc3f2pcar7VAdyqTU3RlE=; b=oYAOQ9f0T7fu3n1pXH5rlVE4WIciLNSm5uqNojpO9bqK5WN6tr/bNkJfL4Rg5nmmMrXpxz 0KMZv/FQ7KY8YT41YrfyRiNU+cW5af2lU8Pp65Sy2Tem4N5gNX2bk3WW3SehkIuNOsu5ku rCahzuyo7iqcbH8g2tZa+Ave/G3b8+4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1719907088; 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=z2S2rdnedmkdXjn0P0IMykHc3f2pcar7VAdyqTU3RlE=; b=SuatxsjBrHw1TThDRpQN07EIGtjjlt6xIiRvcY8mJ3fGID7J+Pgvt0/JwBTbTwf2uS0ez+ ZUvVJe6l4Ppma0BQ== Date: Tue, 2 Jul 2024 09:58:08 +0200 (CEST) From: Richard Biener To: Tamar Christina cc: gcc-patches@gcc.gnu.org, nd@arm.com, jlaw@ventanamicro.com Subject: Re: [PATCH 2/2]middle-end: replace constant_multiple_of with aff_combination_constant_multiple_p [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]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; MISSING_XM_UA(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)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCPT_COUNT_THREE(0.00)[4] 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, > > The current implementation of constant_multiple_of is doing a more limited > version of aff_combination_constant_multiple_p. > > The only non-debug usage of constant_multiple_of will proceed with the values > as affine trees. There is scope for further optimization here, namely I believe > that if constant_multiple_of returns the aff_tree after the conversion then > get_computation_aff_1 can use it instead of manually creating the aff_tree. > > However I think it makes sense to first commit this smaller change and then > incrementally change things. > > Bootstrapped Regtested on aarch64-none-linux-gnu, > x86_64-pc-linux-gnu -m32, -m64 and no issues. > > Ok for master? OK. Thanks, Richard. > Thanks, > Tamar > > gcc/ChangeLog: > > PR tree-optimization/114932 > * tree-ssa-loop-ivopts.cc (constant_multiple_of): Use > aff_combination_constant_multiple_p instead. > > --- > diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc > index 7cae5bdefea3648ddde238a357af527a934a569e..c3218a3e8eedbb8d0a7f14c01eeb069cb6024c29 100644 > --- a/gcc/tree-ssa-loop-ivopts.cc > +++ b/gcc/tree-ssa-loop-ivopts.cc > @@ -2146,65 +2146,15 @@ idx_record_use (tree base, tree *idx, > static bool > constant_multiple_of (tree top, tree bot, widest_int *mul) > { > - tree mby; > - enum tree_code code; > - unsigned precision = TYPE_PRECISION (TREE_TYPE (top)); > - widest_int res, p0, p1; > - > - STRIP_NOPS (top); > - STRIP_NOPS (bot); > - > - if (operand_equal_p (top, bot, 0)) > - { > - *mul = 1; > - return true; > - } > - > - code = TREE_CODE (top); > - switch (code) > - { > - case MULT_EXPR: > - mby = TREE_OPERAND (top, 1); > - if (TREE_CODE (mby) != INTEGER_CST) > - return false; > - > - if (!constant_multiple_of (TREE_OPERAND (top, 0), bot, &res)) > - return false; > - > - *mul = wi::sext (res * wi::to_widest (mby), precision); > - return true; > - > - case PLUS_EXPR: > - case MINUS_EXPR: > - if (!constant_multiple_of (TREE_OPERAND (top, 0), bot, &p0) > - || !constant_multiple_of (TREE_OPERAND (top, 1), bot, &p1)) > - return false; > - > - if (code == MINUS_EXPR) > - p1 = -p1; > - *mul = wi::sext (p0 + p1, precision); > - return true; > - > - case INTEGER_CST: > - if (TREE_CODE (bot) != INTEGER_CST) > - return false; > - > - p0 = widest_int::from (wi::to_wide (top), SIGNED); > - p1 = widest_int::from (wi::to_wide (bot), SIGNED); > - if (p1 == 0) > - return false; > - *mul = wi::sext (wi::divmod_trunc (p0, p1, SIGNED, &res), precision); > - return res == 0; > - > - default: > - if (POLY_INT_CST_P (top) > - && POLY_INT_CST_P (bot) > - && constant_multiple_p (wi::to_poly_widest (top), > - wi::to_poly_widest (bot), mul)) > - return true; > + aff_tree aff_top, aff_bot; > + tree_to_aff_combination (top, TREE_TYPE (top), &aff_top); > + tree_to_aff_combination (bot, TREE_TYPE (bot), &aff_bot); > + poly_widest_int poly_mul; > + if (aff_combination_constant_multiple_p (&aff_top, &aff_bot, &poly_mul) > + && poly_mul.is_constant (mul)) > + return true; > > - return false; > - } > + return false; > } > > /* Return true if memory reference REF with step STEP may be unaligned. */ > > > > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)