From patchwork Fri Feb 4 08:31:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 50790 Return-Path: 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 ; 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 ; 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 ); 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Cc: Jakub Jelinek , richard.sandiford@arm.com, roger@nextmovesoftware.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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 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))