From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 5A9103858D37 for ; Tue, 23 May 2023 15:15:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5A9103858D37 Authentication-Results: sourceware.org; dmarc=pass (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-out2.suse.de (Postfix) with ESMTPS id 77CA51F37C for ; Tue, 23 May 2023 15:15:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1684854948; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=7aY9eobOmfnyWAZwaquon/RIwbPDdXoEaO27rk8kfjo=; b=sMGrtLtnwKtv14Zs+1rpEJEbtKAXURUWUBj5lEQdEsOxDX75S6lst+GmA0UQowiahGjT/I ik2oW7i5TpmYf5VqpuR2F8aVHU7S3o/EwSCDVspbc2DVX4m7AGhwaAz8vA0nokaVLtJw4t EzrSkV3y2U8GsrvrW9rTMcUhp/3xuuo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1684854948; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=7aY9eobOmfnyWAZwaquon/RIwbPDdXoEaO27rk8kfjo=; b=BtFoDKTEjy/0jxoMgGVkJ3VZCjA4L3OsGRMn6OBlloX3j1duhSKHB7ADaQtepMpG0RTcIm R6Cij0nnkRoytIDg== 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 622FF13A10 for ; Tue, 23 May 2023 15:15:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WtfCFqTYbGRHfAAAMHmgww (envelope-from ) for ; Tue, 23 May 2023 15:15:48 +0000 Date: Tue, 23 May 2023 17:15:48 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Generic vector op costing adjustment MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20230523151548.622FF13A10@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 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,T_SCC_BODY_TEXT_LINE 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: This is a small adjustment to the work done for PR108752 and better reflects the cost of the generated sequence. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/108752 * tree-vect-stmts.cc (vectorizable_operation): For bit operations with generic word_mode vectors do not cost an extra stmt. For plus, minus and negate also cost the constant materialization. --- gcc/tree-vect-stmts.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 0022b878767..127b987cd62 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -6466,8 +6466,8 @@ vectorizable_operation (vec_info *vinfo, { /* The above vect_model_simple_cost call handles constants in the prologue and (mis-)costs one of the stmts as - vector stmt. See tree-vect-generic.cc:do_plus_minus/do_negate - for the actual lowering that will be applied. */ + vector stmt. See below for the actual lowering that will + be applied. */ unsigned n = slp_node ? SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node) : ncopies; switch (code) @@ -6481,9 +6481,20 @@ vectorizable_operation (vec_info *vinfo, case NEGATE_EXPR: n *= 4; break; - default:; + default: + /* Bit operations do not have extra cost and are accounted + as vector stmt by vect_model_simple_cost. */ + n = 0; + break; + } + if (n != 0) + { + /* We also need to materialize two large constants. */ + record_stmt_cost (cost_vec, 2, scalar_stmt, stmt_info, + 0, vect_prologue); + record_stmt_cost (cost_vec, n, scalar_stmt, stmt_info, + 0, vect_body); } - record_stmt_cost (cost_vec, n, scalar_stmt, stmt_info, 0, vect_body); } return true; } -- 2.35.3