From patchwork Tue May 23 15:18:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 98046 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3046:b0:115:7a1d:dabb with SMTP id p6csp2204781rwl; Tue, 23 May 2023 08:19:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4bYXxh5V3b3DsQu+/V5Gr0Dm8jQEzJLj8PxnoaKDp4TkvYCZVJ3qvd0HhNtext4fliOVHx X-Received: by 2002:a17:906:db04:b0:957:1df0:9cbf with SMTP id xj4-20020a170906db0400b009571df09cbfmr13378578ejb.19.1684855174216; Tue, 23 May 2023 08:19:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684855174; cv=none; d=google.com; s=arc-20160816; b=aJkRxw6r6sjZfDhBpeBLxbiUwyLdtEABAp3a1tgTaliN0t9uINKldnad3mnhmhm6JZ wcg9GHiqMo1Ogy3B/cBOJZbTZC49hYhKI6oPDdgcdnm1OUJnjT+zjNJADq9wmpqyE6XE KLPAozNZ2T1e6wR+ck8RPcdPnj4X7ev1eXHMCqSgdBR4BXPggOa23PBBsSIODp3Cylyv L3UR2UVQ/T/jYlALvoUC4kbagvn9ezGizuYPAYgtozxqHCeyAoY9un3W8ihuJBTLJG/w wDGHX0LTezAq1CofjnerzvLUUChGV/wEspc+IxBwsDx+LmJTURPuExePKQic7v2I5+V7 oOlA== 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:cc:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=CpUSChdPiUWpRdmW/GVz1wuG25SzXVwvLCkNIEoYSEA=; b=Txj3QsJcgXxf+bI/H9ksuBVTzqgp95TZde0qQX4xxJPvcSkiSttfRlUixQR6J87lIn XXk+QJ+1AHjYrOjhzz1pEqT5pPdzK5eK2J1xcXbJynZVmT3WPz34NR2jkD0G5EYT+CFa nO+8H4SdNGQ4bdNWkAk0BzOm9XRDVYC0YwG45JYuJgPJeIMhL177DVrbA2nygPkNNdDV nDG+bwCIFSNrrQ+BhH1xUC8epA/vcdj+mfzBhwohUNV8gCt3meMElOSglh0D93J3MQKb HZahY+KcSPZpkz4Do18k+Z40/0/14bZ3S6+jYrwpTjQwt/6eRoRJDLz9+Mo9E3rTjadT gSRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ppdKGwP7; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id gr14-20020a170906e2ce00b0096a411a1cf9si977557ejb.940.2023.05.23.08.19.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 08:19:34 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ppdKGwP7; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 1B7813858C00 for ; Tue, 23 May 2023 15:19:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1B7813858C00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684855173; bh=CpUSChdPiUWpRdmW/GVz1wuG25SzXVwvLCkNIEoYSEA=; h=Date:To:cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ppdKGwP74CHmXUKKcnpS3yPRcXZvTGwyXDGEC0eiz1W2gcyoI7xbfVFoI2x1U8sGc MsGCj1WhsCT79icTpNkNt9b/x9XKGeuECAk4QsvsOZ3rMBctdN2cC93hLbUR2krk/A oNawhT8GWKx0VsIX2iaEnnZYs9W8UUa/76qbPTV8= 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 F0F6E3858002 for ; Tue, 23 May 2023 15:18:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F0F6E3858002 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 EF2751FE5B; Tue, 23 May 2023 15:18:45 +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 D26C213A10; Tue, 23 May 2023 15:18:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id fiFBMlXZbGSlfQAAMHmgww (envelope-from ); Tue, 23 May 2023 15:18:45 +0000 Date: Tue, 23 May 2023 17:18:45 +0200 (CEST) To: gcc-patches@gcc.gnu.org cc: ubizjak@gmail.com, hongtao.liu@intel.com Subject: [PATCH] Account for vector splat GPR->XMM move cost MIME-Version: 1.0 Message-Id: <20230523151845.D26C213A10@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.8 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?1766698699090125968?= X-GMAIL-MSGID: =?utf-8?q?1766698699090125968?= The following also accounts for a GPR->XMM move cost for splat operations and properly guards eliding the cost when moving from memory only for SSE4.1 or HImode or larger operands. This doesn't fix the PR fully yet. Bootstrapped and tested on x86_64-unknown-linux-gnu, OK? Thanks, Richard. PR target/109944 * config/i386/i386.cc (ix86_vector_costs::add_stmt_cost): For vector construction or splats apply GPR->XMM move costing. QImode memory can be handled directly only with SSE4.1 pinsrb. --- gcc/config/i386/i386.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index 38125ce284a..011a1fb0d6d 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -23654,7 +23654,7 @@ ix86_vector_costs::add_stmt_cost (int count, vect_cost_for_stmt kind, stmt_cost = ix86_builtin_vectorization_cost (kind, vectype, misalign); stmt_cost *= (TYPE_VECTOR_SUBPARTS (vectype) + 1); } - else if (kind == vec_construct + else if ((kind == vec_construct || kind == scalar_to_vec) && node && SLP_TREE_DEF_TYPE (node) == vect_external_def && INTEGRAL_TYPE_P (TREE_TYPE (vectype))) @@ -23687,7 +23687,9 @@ ix86_vector_costs::add_stmt_cost (int count, vect_cost_for_stmt kind, Likewise with a BIT_FIELD_REF extracting from a vector register we can hope to avoid using a GPR. */ if (!is_gimple_assign (def) - || (!gimple_assign_load_p (def) + || ((!gimple_assign_load_p (def) + || (!TARGET_SSE4_1 + && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op))) == 1)) && (gimple_assign_rhs_code (def) != BIT_FIELD_REF || !VECTOR_TYPE_P (TREE_TYPE (TREE_OPERAND (gimple_assign_rhs1 (def), 0))))))