From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7861) id 1C7C63858D35; Thu, 29 Jun 2023 00:04:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1C7C63858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687997060; bh=4BTzSYYsX0VjRZRqZDnSE0mYRlhT5XwyRYcakoYP7Os=; h=From:To:Subject:Date:From; b=el1lHLF8mcxhTkRK6nhQTqb6effRF24xXnskDPgKfpSBrqnVwW/2KPjvywXNJeh1c AWo9wR21yluDAaodjm/47Ao+bOO42Z6bIxAiY+ITQ6nN+VQo/hvQMfaZ2C1t6jAKOb bqccgMcu3JlbxjDCyQhFoF9HmZAZd379rbpw6OyQ= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Hongyu Wang To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-7497] i386: Sync tune_string with arch_string for target attribute arch=* X-Act-Checkin: gcc X-Git-Author: Hongyu Wang X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: f2eeda5652438fe783d4e3878139481a1b8606b6 X-Git-Newrev: 99c0b27cf49dd2913c2249d351ba33254dbb2743 Message-Id: <20230629000420.1C7C63858D35@sourceware.org> Date: Thu, 29 Jun 2023 00:04:20 +0000 (GMT) List-Id: https://gcc.gnu.org/g:99c0b27cf49dd2913c2249d351ba33254dbb2743 commit r13-7497-g99c0b27cf49dd2913c2249d351ba33254dbb2743 Author: Hongyu Wang Date: Sun Jun 25 09:50:21 2023 +0800 i386: Sync tune_string with arch_string for target attribute arch=* 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. 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. (cherry picked from commit 2916278d14e9ac28c361c396a67256acbebda6e8) Diff: --- gcc/config/i386/i386-options.cc | 6 +++++- gcc/testsuite/gcc.target/i386/mvc17.c | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc index f76e7c5947b..37cb5a0dcc4 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..8b83c1aecb3 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mvc17.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "-O2 -march=x86-64" } */ +/* { 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); +}