From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 05EAC386FC17 for ; Tue, 27 Jul 2021 08:41:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 05EAC386FC17 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de 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-out1.suse.de (Postfix) with ESMTPS id CAE1B22041 for ; Tue, 27 Jul 2021 08:41:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1627375278; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=VQqzXk0W2S9LUOKHsGM4+IOLFeyBSwCbrB9JNbvqmZ4=; b=wsFLRsHbYNnKDG/w0jh6tTOMmavzQMb/BPjbyocjyRKpTkUabHfvr+iBIopV4F6Ts1gu6s jpXqmwIzmTrUNke3+IEqiryZiNT1GENTuiSSK2ks12D0ctgZpQ7Ifl9FJvgiuj3YJEyle9 fZ2ATbU/5vv6cpZz93nDyHCe+cOkc94= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1627375278; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=VQqzXk0W2S9LUOKHsGM4+IOLFeyBSwCbrB9JNbvqmZ4=; b=GKXi07PV4GI1cCAe2nqmptpiCBlmIA4xsJVv7T6qFAUXvOCMaVii6gMXXcB1mD2GXmBhGQ 3sQoilqOPb5jK0Aw== 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 B643A1377D for ; Tue, 27 Jul 2021 08:41:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id nJ9IK67G/2CsagAAMHmgww (envelope-from ) for ; Tue, 27 Jul 2021 08:41:18 +0000 Date: Tue, 27 Jul 2021 10:41:18 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/39821 - fix cost classification for widening arith Message-ID: <122q6r7-351o-74os-87ss-q3rp695qnq3r@fhfr.qr> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-11.3 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.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-List-Received-Date: Tue, 27 Jul 2021 08:41:21 -0000 This adjusts the vectorizer to cost vector_stmt for widening arithmetic instead of vec_promote_demote in the line of telling the target that stmt_info->stmt is the meaningful piece we cost. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2021-07-27 Richard Biener PR tree-optimization/39821 * tree-vect-stmts.c (vect_model_promotion_demotion_cost): Use vector_stmt for widening arithmetic. (vectorizable_conversion): Adjust. --- gcc/tree-vect-stmts.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index d71552296bb..074dfdcf385 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -836,20 +836,24 @@ vect_model_simple_cost (vec_info *, one if two-step promotion/demotion is required, and so on. NCOPIES is the number of vector results (and thus number of instructions) for the narrowest end of the operation chain. Each additional - step doubles the number of instructions required. */ + step doubles the number of instructions required. If WIDEN_ARITH + is true the stmt is doing widening arithmetic. */ static void vect_model_promotion_demotion_cost (stmt_vec_info stmt_info, enum vect_def_type *dt, unsigned int ncopies, int pwr, - stmt_vector_for_cost *cost_vec) + stmt_vector_for_cost *cost_vec, + bool widen_arith) { int i; int inside_cost = 0, prologue_cost = 0; for (i = 0; i < pwr + 1; i++) { - inside_cost += record_stmt_cost (cost_vec, ncopies, vec_promote_demote, + inside_cost += record_stmt_cost (cost_vec, ncopies, + widen_arith + ? vector_stmt : vec_promote_demote, stmt_info, 0, vect_body); ncopies *= 2; } @@ -4690,6 +4694,10 @@ vectorizable_conversion (vec_info *vinfo, && code != WIDEN_LSHIFT_EXPR) return false; + bool widen_arith = (code == WIDEN_PLUS_EXPR + || code == WIDEN_MINUS_EXPR + || code == WIDEN_MULT_EXPR + || code == WIDEN_LSHIFT_EXPR); op_type = TREE_CODE_LENGTH (code); /* Check types of lhs and rhs. */ @@ -4779,10 +4787,7 @@ vectorizable_conversion (vec_info *vinfo, nunits_in = TYPE_VECTOR_SUBPARTS (vectype_in); nunits_out = TYPE_VECTOR_SUBPARTS (vectype_out); if (known_eq (nunits_out, nunits_in)) - if (code == WIDEN_MINUS_EXPR - || code == WIDEN_PLUS_EXPR - || code == WIDEN_LSHIFT_EXPR - || code == WIDEN_MULT_EXPR) + if (widen_arith) modifier = WIDEN; else modifier = NONE; @@ -4959,7 +4964,8 @@ vectorizable_conversion (vec_info *vinfo, unsigned int nvectors = (slp_node ? SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node) : ncopies); vect_model_promotion_demotion_cost (stmt_info, dt, nvectors, - multi_step_cvt, cost_vec); + multi_step_cvt, cost_vec, + widen_arith); } else { @@ -4972,7 +4978,8 @@ vectorizable_conversion (vec_info *vinfo, ? SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node) >> multi_step_cvt : ncopies * 2); vect_model_promotion_demotion_cost (stmt_info, dt, nvectors, - multi_step_cvt, cost_vec); + multi_step_cvt, cost_vec, + widen_arith); } interm_types.release (); return true; -- 2.26.2