Message ID | 20220204083120.AB72A1331A@imap2.suse-dmz.suse.de |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AC4A43858C20 for <patchwork@sourceware.org>; Fri, 4 Feb 2022 08:31:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC4A43858C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1643963510; bh=wZ0xfAa30kHr82KFWDRjK9lcgoSlzC7mljn5tiyBrHg=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=q30w8i/2BIxfmDs/0gw4NuWBBEyLm7+m/MS5+oyPZ0gZvcTsysJNdRGxpHCanrJ9L +rr7PuPjWQJiIi9SkE4js1UkL6gbNcO0mR+iNpNXZTCLf/9cvWUolUqqBNlGmNC9O6 a0SH68yzb082WtGAjcHf84lAUhHMc9ksN5zlkMxE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 185A53858D35 for <gcc-patches@gcc.gnu.org>; Fri, 4 Feb 2022 08:31:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 185A53858D35 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 CD0E11F44E; Fri, 4 Feb 2022 08:31:20 +0000 (UTC) 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 AB72A1331A; Fri, 4 Feb 2022 08:31:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id fBS1KFjk/GFqYAAAMHmgww (envelope-from <rguenther@suse.de>); Fri, 04 Feb 2022 08:31:20 +0000 Date: Fri, 4 Feb 2022 09:31:20 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/103641 - improve vect_synth_mult_by_constant MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20220204083120.AB72A1331A@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Richard Biener <rguenther@suse.de> Cc: Jakub Jelinek <jakub@redhat.com>, richard.sandiford@arm.com, roger@nextmovesoftware.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
tree-optimization/103641 - improve vect_synth_mult_by_constant
|
|
Commit Message
Richard Biener
Feb. 4, 2022, 8:31 a.m. UTC
The following happens to improve compile-time of the PR103641 testcase on aarch64 significantly. I did not investigate the effect on the generated code but at least in theory choose_mult_variant should do a better job when we tell it the actual mode we are going to use for the operations it synthesizes. Bootstrapped and tested on x86_64-unknown-linux-gnu. OK for trunk? Thanks, Richard. 2022-02-04 Richard Biener <rguenther@suse.de> PR tree-optimization/103641 * tree-vect-patterns.cc (vect_synth_mult_by_constant): Pass the vector mode to choose_mult_variant. --- gcc/tree-vect-patterns.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Comments
Richard Biener <rguenther@suse.de> writes: > The following happens to improve compile-time of the PR103641 > testcase on aarch64 significantly. I did not investigate the > effect on the generated code but at least in theory > choose_mult_variant should do a better job when we tell it > the actual mode we are going to use for the operations it > synthesizes. Yeah, agreed. (Following up from a comment in the PR: I don't think we can rely on unsupported operations having a high cost, but then we should already be checking that the operations are actually supported.) > Bootstrapped and tested on x86_64-unknown-linux-gnu. > > OK for trunk? > > Thanks, > Richard. > > 2022-02-04 Richard Biener <rguenther@suse.de> > > PR tree-optimization/103641 > * tree-vect-patterns.cc (vect_synth_mult_by_constant): > Pass the vector mode to choose_mult_variant. > --- > gcc/tree-vect-patterns.cc | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc > index bea04992160..686a10caec1 100644 > --- a/gcc/tree-vect-patterns.cc > +++ b/gcc/tree-vect-patterns.cc > @@ -3046,17 +3046,17 @@ vect_synth_mult_by_constant (vec_info *vinfo, tree op, tree val, > can synthesize shifts that way. */ > bool synth_shift_p = !vect_supportable_shift (vinfo, LSHIFT_EXPR, multtype); > > + tree vectype = get_vectype_for_scalar_type (vinfo, multtype); > HOST_WIDE_INT hwval = tree_to_shwi (val); > /* Use MAX_COST here as we don't want to limit the sequence on rtx costs. > The vectorizer's benefit analysis will decide whether it's beneficial > to do this. */ > - bool possible = choose_mult_variant (mode, hwval, &alg, > - &variant, MAX_COST); > + bool possible = choose_mult_variant (VECTOR_MODE_P (TYPE_MODE (vectype)) > + ? TYPE_MODE (vectype) : mode, > + hwval, &alg, &variant, MAX_COST); > if (!possible) > return NULL; > > - tree vectype = get_vectype_for_scalar_type (vinfo, multtype); > - > if (!vectype > || !target_supports_mult_synth_alg (&alg, variant, > vectype, synth_shift_p)) The !vectype early out needs to move with the assignment. LGTM otherwise. Thanks, Richard
On Fri, Feb 04, 2022 at 09:31:20AM +0100, Richard Biener wrote: > The following happens to improve compile-time of the PR103641 > testcase on aarch64 significantly. I did not investigate the > effect on the generated code but at least in theory > choose_mult_variant should do a better job when we tell it > the actual mode we are going to use for the operations it > synthesizes. > > Bootstrapped and tested on x86_64-unknown-linux-gnu. > > OK for trunk? > > Thanks, > Richard. > > 2022-02-04 Richard Biener <rguenther@suse.de> > > PR tree-optimization/103641 > * tree-vect-patterns.cc (vect_synth_mult_by_constant): > Pass the vector mode to choose_mult_variant. LGTM. Jakub
On Fri, 4 Feb 2022, Richard Sandiford wrote: > Richard Biener <rguenther@suse.de> writes: > > The following happens to improve compile-time of the PR103641 > > testcase on aarch64 significantly. I did not investigate the > > effect on the generated code but at least in theory > > choose_mult_variant should do a better job when we tell it > > the actual mode we are going to use for the operations it > > synthesizes. > > Yeah, agreed. (Following up from a comment in the PR: I don't think > we can rely on unsupported operations having a high cost, but then we > should already be checking that the operations are actually supported.) > > > Bootstrapped and tested on x86_64-unknown-linux-gnu. > > > > OK for trunk? > > > > Thanks, > > Richard. > > > > 2022-02-04 Richard Biener <rguenther@suse.de> > > > > PR tree-optimization/103641 > > * tree-vect-patterns.cc (vect_synth_mult_by_constant): > > Pass the vector mode to choose_mult_variant. > > --- > > gcc/tree-vect-patterns.cc | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc > > index bea04992160..686a10caec1 100644 > > --- a/gcc/tree-vect-patterns.cc > > +++ b/gcc/tree-vect-patterns.cc > > @@ -3046,17 +3046,17 @@ vect_synth_mult_by_constant (vec_info *vinfo, tree op, tree val, > > can synthesize shifts that way. */ > > bool synth_shift_p = !vect_supportable_shift (vinfo, LSHIFT_EXPR, multtype); > > > > + tree vectype = get_vectype_for_scalar_type (vinfo, multtype); > > HOST_WIDE_INT hwval = tree_to_shwi (val); > > /* Use MAX_COST here as we don't want to limit the sequence on rtx costs. > > The vectorizer's benefit analysis will decide whether it's beneficial > > to do this. */ > > - bool possible = choose_mult_variant (mode, hwval, &alg, > > - &variant, MAX_COST); > > + bool possible = choose_mult_variant (VECTOR_MODE_P (TYPE_MODE (vectype)) > > + ? TYPE_MODE (vectype) : mode, > > + hwval, &alg, &variant, MAX_COST); > > if (!possible) > > return NULL; > > > > - tree vectype = get_vectype_for_scalar_type (vinfo, multtype); > > - > > if (!vectype > > || !target_supports_mult_synth_alg (&alg, variant, > > vectype, synth_shift_p)) > > The !vectype early out needs to move with the assignment. > LGTM otherwise. Whoops yes - missed that. Will push after that fixed. Richard.
diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index bea04992160..686a10caec1 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -3046,17 +3046,17 @@ vect_synth_mult_by_constant (vec_info *vinfo, tree op, tree val, can synthesize shifts that way. */ bool synth_shift_p = !vect_supportable_shift (vinfo, LSHIFT_EXPR, multtype); + tree vectype = get_vectype_for_scalar_type (vinfo, multtype); HOST_WIDE_INT hwval = tree_to_shwi (val); /* Use MAX_COST here as we don't want to limit the sequence on rtx costs. The vectorizer's benefit analysis will decide whether it's beneficial to do this. */ - bool possible = choose_mult_variant (mode, hwval, &alg, - &variant, MAX_COST); + bool possible = choose_mult_variant (VECTOR_MODE_P (TYPE_MODE (vectype)) + ? TYPE_MODE (vectype) : mode, + hwval, &alg, &variant, MAX_COST); if (!possible) return NULL; - tree vectype = get_vectype_for_scalar_type (vinfo, multtype); - if (!vectype || !target_supports_mult_synth_alg (&alg, variant, vectype, synth_shift_p))