From patchwork Thu Feb 28 18:28:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1049685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-497166-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="iipJKj3X"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 449Lf43Wlpz9s2R for ; Fri, 1 Mar 2019 05:28:24 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding; q=dns; s=default; b=nI8ytfXtjLdJ0Jku uhQ7kTgW7VUee3KePsZONJUH3BV9mcN8OyoeZJsnioT4614TzRN47LifAv7ZpQkc wEec+2syOqSCmck5UFd+FOUC5dzSEpIMcgpHIGZEBIPAwW33Ra3ooj/0GSmYm5nJ uxpPF5d8wxrVX5ZN5Qt/dKz0les= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=default; bh=pn8Gi6gpO+m8AwO8qG0J/G gYL0Y=; b=iipJKj3XqjdY1NQr2cSv2+rfEVOGRnRgZo5OxOE4w42+Z4mGqatby5 Lta4bPrGA6962JWPEajs/WrgJ9aV9d2f6o9wub50SVunUxllRaH8AV2cdfmgcKbD dgNXF9byL3yaDSYm1Ej9+giXiaRncxmA/9rHm3kUP3pa4vSCKvGls= Received: (qmail 22984 invoked by alias); 28 Feb 2019 18:28:17 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 22961 invoked by uid 89); 28 Feb 2019 18:28:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=HContent-Transfer-Encoding:8bit X-HELO: mga04.intel.com Received: from mga04.intel.com (HELO mga04.intel.com) (192.55.52.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 28 Feb 2019 18:28:15 +0000 Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Feb 2019 10:28:14 -0800 Received: from gnu-cfl-1.sc.intel.com ([172.25.70.237]) by fmsmga007.fm.intel.com with ESMTP; 28 Feb 2019 10:28:13 -0800 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Cc: Uros Bizjak Subject: [PATCH] i386: Support ISAs enabled at command-line with target attribute Date: Thu, 28 Feb 2019 10:28:13 -0800 Message-Id: <20190228182813.20992-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-IsSubscribed: yes __attribute__ ((target("arch=broadwell"))) should enable AVX with -mavx at command-line. When we apply target attribute, we need to clear x_ix86_isa_flags_explicit and x_ix86_isa_flags2_explicit, which are turned on at command-line, so that target features will be enabled. mv17.C has a version for Haswell. On machines with Haswell ISAs, when GCC is configured with --with-arch=native, all versions will be compiled with Haswell ISAs. Compile mv17.C with -march=x86-64 to force that only Haswell version is compiled with -march=haswell. gcc/ PR target/89456 * config/i386/i386.c (ix86_valid_target_attribute_tree): Allow enabling ISAs which have been enabled at command-line. gcc/testsuite/ PR target/89456 * g++.target/i386/mv17.C: Add -march=x86-64. * gcc.target/i386/pr89456-1.c: New test. --- gcc/config/i386/i386.c | 6 ++++++ gcc/testsuite/g++.target/i386/mv17.C | 2 +- gcc/testsuite/gcc.target/i386/pr89456-1.c | 9 +++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr89456-1.c diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index c8f9957163b..2b72ca8359f 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -5539,6 +5539,12 @@ ix86_valid_target_attribute_tree (tree args, = TREE_TARGET_OPTION (target_option_default_node); struct gcc_options enum_opts_set; + /* Allow enabling ISAs which have been enabled at command-line so + that __attribute__ ((target("arch=broadwell"))) enables AVX when + there is -mavx at command-line. */ + opts->x_ix86_isa_flags_explicit &= ~ix86_isa_flags; + opts->x_ix86_isa_flags2_explicit &= ~ix86_isa_flags2; + memset (&enum_opts_set, 0, sizeof (enum_opts_set)); /* Process each of the options on the chain. */ diff --git a/gcc/testsuite/g++.target/i386/mv17.C b/gcc/testsuite/g++.target/i386/mv17.C index fefbfaac6ff..17d125227d7 100644 --- a/gcc/testsuite/g++.target/i386/mv17.C +++ b/gcc/testsuite/g++.target/i386/mv17.C @@ -2,7 +2,7 @@ // { dg-do run } // { dg-require-ifunc "" } -// { dg-options "-O2" } +// { dg-options "-O2 -march=x86-64" } #include diff --git a/gcc/testsuite/gcc.target/i386/pr89456-1.c b/gcc/testsuite/gcc.target/i386/pr89456-1.c new file mode 100644 index 00000000000..87a3a820898 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr89456-1.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx -march=x86-64" } */ + +__attribute__ ((target("arch=broadwell"))) +float +foo (float x) +{ + return x; +}