From patchwork Tue May 23 15:15:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 98043 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3046:b0:115:7a1d:dabb with SMTP id p6csp2202592rwl; Tue, 23 May 2023 08:16:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5yaoCbI2nLqNfQzRIwXivr5ifXvxVxduklXuwi0/9B+KCOJPwrik5OLPQBDqw3crnMUY82 X-Received: by 2002:a17:907:96aa:b0:96f:d556:b926 with SMTP id hd42-20020a17090796aa00b0096fd556b926mr7232922ejc.77.1684854995710; Tue, 23 May 2023 08:16:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684854995; cv=none; d=google.com; s=arc-20160816; b=wVoBiJmUZdPKo7X8JuwRgq4lIyQlLRhfi1KWRGWjxyE+HWZHvy8AJToD+cFnoa1NBC JsLMa1PKTKZgDcJQBbaeDjjwxtnM8nCiAOuyPKGu/Q79+5lilhkpwrERtD5GsDRiEIwP 9veaGQb93SnTm5nouJ6xHmikAG1g4A6fvzaK1/8y0ZRcqy9Hb0TS1XiBl3poWElWUseh jta1k/Ft/VYyb1TFLbofi5KLaLzYGcnRwvNB/y5vQqmsQEoC1VF9GO49C+kX0qPdrzCV tRzum1O2Fr6eF3aaFOpopKfhrpbfnr3ULaGHgLDZjQpo0JpcTQ6Fo00KJJT4o/hu9lXr 96fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=7aY9eobOmfnyWAZwaquon/RIwbPDdXoEaO27rk8kfjo=; b=XhyYDhsOZHBwAOu7Y9FTB1ULE+TjwEdBtAf+ty9rtZfOXv35NlaMcVaY4M+a8SnP1u uVmfTQnCAwgs8mGNFq675GX0ZGupdEuoFXIo+Mw/LHgOHxauYtRVjrRrGk9N9PUK6iQg gQazxKtJrcJ23XRg5Lqd+D2hH/JBGz1b9UZ2je1yTtKKS2v+AQfDTvMFkd4crcQaOU60 8A4ileMPlKmmpvJKJz/tshdaE4CkJfQjIBj0X3jCsxqt4DAiQ2rD/QkpixxsIhfT01HB 7Ct06fJIIt2REtPBGI9UKigAlPYnnCJd9f3mw0k+Pkk/qBuZY83zwFPlBFyQM2vxBdOP zX8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=APvlANMY; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id z11-20020a170906240b00b0094f3a2fa2cfsi704511eja.146.2023.05.23.08.16.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 08:16:35 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=APvlANMY; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 42A9D385828D for ; Tue, 23 May 2023 15:16:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42A9D385828D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684854994; bh=7aY9eobOmfnyWAZwaquon/RIwbPDdXoEaO27rk8kfjo=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=APvlANMYg3/vJhM08nE5rH6y7NyS1CQjoKL7uCwIpXRI/vu+sispypKS+S8QcQPZ4 heWH7lG4OKEtMsb1Ns4wtrxRAPLNGfiV9feTVKB7fb/qKR7u96yXbLpPHK7SxnRAwc wB4vODYQlXZaoWe3NJey+SS+6R4UNfQ/Z4F0ar20= 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 [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 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) 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) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Generic vector op costing adjustment MIME-Version: 1.0 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 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 Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766698512074152765?= X-GMAIL-MSGID: =?utf-8?q?1766698512074152765?= 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; }