From patchwork Mon Sep 6 15:06:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 63929 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 4CA6BB712A for ; Tue, 7 Sep 2010 01:07:37 +1000 (EST) Received: (qmail 29152 invoked by alias); 6 Sep 2010 15:07:35 -0000 Received: (qmail 29144 invoked by uid 22791); 6 Sep 2010 15:07:34 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL, BAYES_00, NO_DNS_FOR_FROM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga03.intel.com (HELO mga03.intel.com) (143.182.124.21) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 06 Sep 2010 15:07:00 +0000 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 06 Sep 2010 08:06:57 -0700 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.135]) by azsmga001.ch.intel.com with ESMTP; 06 Sep 2010 08:06:57 -0700 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id DC92C22683; Mon, 6 Sep 2010 08:06:56 -0700 (PDT) Date: Mon, 6 Sep 2010 08:06:56 -0700 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Cc: Uros Bizjak Subject: PATCH: PR target/45483: probably wrong optimization options chosen by "-march=native" Message-ID: <20100906150656.GA11565@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) 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 We may guess best options for -march=native. We may leave out SSE3 or SSSE3. This patch adds it. OK for trunk and 4.5? Thanks. H.J. ---- 2010-09-06 H.J. Lu PR target/45483 * config/i386/driver-i386.c (host_detect_local_cpu): Add -mssse3 or -msse3 if needed. diff --git a/gcc/config/i386/driver-i386.c b/gcc/config/i386/driver-i386.c index 8a76857..d132582 100644 --- a/gcc/config/i386/driver-i386.c +++ b/gcc/config/i386/driver-i386.c @@ -549,6 +549,9 @@ const char *host_detect_local_cpu (int argc, const char **argv) case 0x26: /* Atom. */ cpu = "atom"; + /* No need to add -mssse3, -msse3. */ + has_sse3 = 0; + has_ssse3 = 0; break; case 0x1a: case 0x1e: @@ -556,20 +559,34 @@ const char *host_detect_local_cpu (int argc, const char **argv) case 0x2e: /* FIXME: Optimize for Nehalem. */ cpu = "core2"; + /* No need to add -mssse3, -msse3. + FIXME: No need for -msse4.2. */ + has_sse3 = 0; + has_ssse3 = 0; break; case 0x25: case 0x2f: /* FIXME: Optimize for Westmere. */ cpu = "core2"; + /* No need to add -mssse3, -msse3. + FIXME: No need for -msse4.2. */ + has_sse3 = 0; + has_ssse3 = 0; break; case 0x17: case 0x1d: /* Penryn. FIXME: -mtune=core2 is slower than -mtune=generic */ cpu = "core2"; + /* No need to add -mssse3, -msse3. */ + has_sse3 = 0; + has_ssse3 = 0; break; case 0x0f: /* Merom. FIXME: -mtune=core2 is slower than -mtune=generic */ cpu = "core2"; + /* No need to add -mssse3, -msse3. */ + has_sse3 = 0; + has_ssse3 = 0; break; default: if (arch) @@ -606,6 +623,8 @@ const char *host_detect_local_cpu (int argc, const char **argv) cpu = "nocona"; else cpu = "prescott"; + /* No need to add -msse3. */ + has_sse3 = 0; } else cpu = "pentium4"; @@ -693,6 +712,10 @@ const char *host_detect_local_cpu (int argc, const char **argv) options = concat (options, " -msse4.2", NULL); else if (has_sse4_1) options = concat (options, " -msse4.1", NULL); + else if (has_ssse3) + options = concat (options, " -mssse3", NULL); + else if (has_sse3) + options = concat (options, " -msse3", NULL); } done: