From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687746683; x=1719282683; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=d4u2zLu59lImG+1rvd8sursU6m1zQy/xVky4Wc800MQ=; b=O+EDsrwycELHHF345Q74GrQRwjEKBDXbky1mPgfXhldv+OCrgizW8ZFC cOlFf3F+uHbxppOo6UVGX2KBK0SjnlfScqN36Uk008akGtcCB3UDWYNAG ajIo2AYZRXVrQe4PGNkhGwvcHp9i6dc2HXgiAesnsvdaW32c1TwokGadf cC3bjbVyi7mRZroKTQEhPh7SF2d59kzLiT0OprmkMBmrIf0RtPusbnyL7 /2+cYfXDUtfGWsW2cybVkVaLpg5xBIYM0+7kDsTHrN5yg+es6auAXsm4c pZMBGMcXGyHH0yzIqFsir4oeVrsm8bRMQMxeyshQA2vnoDEqNVzJ5lUOO Q==; 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) From: Hongyu Wang 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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); +} -- 2.31.1