From patchwork Mon Jun 26 02:29:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongyu Wang X-Patchwork-Id: 112698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7202421vqr; Sun, 25 Jun 2023 19:32:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7V1P3n/lrmTC3SqzcFTDvuH4ADtS8J4LitRNClppJNbJ4+5I1pISWkeTOiKhfXhKaRRRYz X-Received: by 2002:a17:907:6289:b0:987:1df4:f32e with SMTP id nd9-20020a170907628900b009871df4f32emr21176761ejc.28.1687746727916; Sun, 25 Jun 2023 19:32:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687746727; cv=none; d=google.com; s=arc-20160816; b=tiHsqYIPVSNxbPl6N50HXdgOzWVBPawRiYd2iEDqJKi2mhOX4E+wuU+783dlmwflBt 8bB9Om6M90Gwtx5uVgS7jOQcC0Xg/rvfFdXUCx9cmItdnyrA1TMsrgPVoAuodDN4BML8 yMRW3UbFIu9gUw8KV2dlguTkst7PnxL0hk7/1OtuM1ZMlOsjNt/cGlbc7POPWbL5hrC8 X7zOmTk3YECjmyPcNhHehOMZ4yzAwBhajhTx0TvStZCcc5DGt56eKuv84EOCHd+QGfvW GnrLQgVRZMGMG7OgWTX4thum2DdhUZhfmgXbDpsyzfkKmPUZu4xVxdRrql9zDGIaXP1g JFaA== 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 :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=SpMs+9nF1XvgJKneWxwllKXCyFkbZ3ralPoa1w/3hEU=; fh=n8eNxIWSYJwy/CU3QSXzDvE/zeEoomCGojuOcYEQEyQ=; b=tpzNnz4RflVd+1x7fJDVsGpxibBThMjwYyDKq8AO0kYOtrsmmNUOZKo3RhDYG86v8n NKh0q/Dkod5uYGPqvF0F76g4B/HfExoUIh9vk/w6dLffqkDk5G+XJiezv5QL5+YjUaqR 27YQuAHH1s8dcud4Xsq3ICX094bWRpg84VlTdgAoMFuLVU+CN2MP3FH9ygg1RSPolRRM 33FiDNDxtaWF3Si6+zJqU+ZhIs2VOp3wlH7wKG/2X8f+Mxj8cuHSUCUO+aIOWnMF2/pu e8Bak/8LsJ8kULjk4f6LoEwjCIZdYcDMv5Gk48f9ZFqlIk6x6REvR0dQaGE4HOtP8bTN cvjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xT2eaXqA; 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 u21-20020a1709064ad500b00978ae651cacsi2286381ejt.0.2023.06.25.19.32.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jun 2023 19:32:07 -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=xT2eaXqA; 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 D7FAB3858C30 for ; Mon, 26 Jun 2023 02:32:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7FAB3858C30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687746726; bh=SpMs+9nF1XvgJKneWxwllKXCyFkbZ3ralPoa1w/3hEU=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=xT2eaXqA6dZJTrIetFx8gBoohOkQnaeDDXaoPN0wUfh3BhRas3Iv/KjHyOg+vW9Zr 5AeZg1nYlCEwY5gtcjFhw3SGWwZ94vkXCJ+rdRcP4Znu0zkNDrXUaiSXv/98utF4FB Ds8Q1e1frjM8JrbisHt3Id7RACKW4Hu7zLZ+jTC4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by sourceware.org (Postfix) with ESMTPS id 3F0273858D20 for ; Mon, 26 Jun 2023 02:31:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3F0273858D20 X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="360020694" X-IronPort-AV: E=Sophos;i="6.01,158,1684825200"; d="scan'208";a="360020694" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2023 19:31:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="840105875" X-IronPort-AV: E=Sophos;i="6.01,158,1684825200"; d="scan'208";a="840105875" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by orsmga004.jf.intel.com with ESMTP; 25 Jun 2023 19:31:15 -0700 Received: from shliclel4217.sh.intel.com (shliclel4217.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 4FE9D100570C; Mon, 26 Jun 2023 10:31:13 +0800 (CST) To: gcc-patches@gcc.gnu.org Cc: ubizjak@gmail.com, hongtao.liu@intel.com Subject: [PATCH] i386: Sync tune_string with arch_string for target attribute arch=* Date: Mon, 26 Jun 2023 10:29:13 +0800 Message-Id: <20230626022913.32556-1-hongyu.wang@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_SHORT, SPF_HELO_NONE, SPF_SOFTFAIL, 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: Hongyu Wang via Gcc-patches From: Hongyu Wang Reply-To: Hongyu Wang 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?1769730712900335327?= X-GMAIL-MSGID: =?utf-8?q?1769730712900335327?= Hi, For function with target attribute arch=*, current logic will set its tune to -mtune from command line so all target_clones will get same tuning flags which would affect the performance for each clone. Override tune with arch if tune was not explicitly specified to get proper tuning flags for target_clones. Bootstrapped/regtested on x86_64-pc-linux-gnu{-m32,} Ok for trunk and backport to active release branches? gcc/ChangeLog: * config/i386/i386-options.cc (ix86_valid_target_attribute_tree): Override tune_string with arch_string if tune_string is not explicitly specified. gcc/testsuite/ChangeLog: * gcc.target/i386/mvc17.c: New test. --- gcc/config/i386/i386-options.cc | 6 +++++- gcc/testsuite/gcc.target/i386/mvc17.c | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/mvc17.c diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc index 2cb0bddcd35..7f593cebe76 100644 --- a/gcc/config/i386/i386-options.cc +++ b/gcc/config/i386/i386-options.cc @@ -1400,7 +1400,11 @@ ix86_valid_target_attribute_tree (tree fndecl, tree args, if (option_strings[IX86_FUNCTION_SPECIFIC_TUNE]) opts->x_ix86_tune_string = ggc_strdup (option_strings[IX86_FUNCTION_SPECIFIC_TUNE]); - else if (orig_tune_defaulted) + /* If we have explicit arch string and no tune string specified, set + tune_string to NULL and later it will be overriden by arch_string + so target clones can get proper optimization. */ + else if (option_strings[IX86_FUNCTION_SPECIFIC_ARCH] + || orig_tune_defaulted) opts->x_ix86_tune_string = NULL; /* If fpmath= is not set, and we now have sse2 on 32-bit, use it. */ diff --git a/gcc/testsuite/gcc.target/i386/mvc17.c b/gcc/testsuite/gcc.target/i386/mvc17.c new file mode 100644 index 00000000000..2c7cc2fdace --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mvc17.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-times "rep mov" 1 } } */ + +__attribute__((target_clones("default","arch=icelake-server"))) +void +foo (char *a, char *b, int size) +{ + __builtin_memcpy (a, b, size & 0x7F); +}