From patchwork Tue Jul 24 14:43:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 172893 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 C652F2C039F for ; Wed, 25 Jul 2012 00:43:58 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1343745840; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=L/A/kxA E8lxhFwWZ5liMKmRYkOE=; b=CwUBAh1qf+uwtpWAeuLofPzLZYmvWLnFt2F2ijZ a5XpxTmGPdUkgD5wg0nZTKGiQF3xAtDnDVfcUv0QM2wqVE3QDOV8P+FbcVcsp4sq QXbxkyXiKjtQAXW6aCvdj0fEAsVECSY2yJzi8pr3zIj+32KXM0efT80iz8IJGwR4 Gjds= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=C3+AVmH6DqlSPxFnXAdBtuK90Zl8FYmHiqKni/j8suhm8hJtcc1jKU8A7PXKF1 rb+GBA6UKl6LwMeoAPAF+aFBgmuLL65PX7lbJDUj9VzIcCcYG11sDR9cmE+LPFDl DZitD9rdV34a6tSoIPSKDsKVMO+qQWfiO5P157tMWb/Y0=; Received: (qmail 16152 invoked by alias); 24 Jul 2012 14:43:54 -0000 Received: (qmail 16134 invoked by uid 22791); 24 Jul 2012 14:43:51 -0000 X-SWARE-Spam-Status: No, hits=-4.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-pb0-f47.google.com (HELO mail-pb0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 24 Jul 2012 14:43:30 +0000 Received: by pbbrq2 with SMTP id rq2so12867598pbb.20 for ; Tue, 24 Jul 2012 07:43:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.232.170 with SMTP id tp10mr45736569pbc.59.1343141010140; Tue, 24 Jul 2012 07:43:30 -0700 (PDT) Received: by 10.66.11.130 with HTTP; Tue, 24 Jul 2012 07:43:30 -0700 (PDT) Date: Tue, 24 Jul 2012 16:43:30 +0200 Message-ID: Subject: Re: [PATCH] Intrinsics for PREFETCHW From: Uros Bizjak To: Kirill Yukhin Cc: Jakub Jelinek , gcc-patches@gcc.gnu.org, Michael Zolotukhin , "H.J. Lu" 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 On Tue, Jul 24, 2012 at 4:06 PM, Kirill Yukhin wrote: >> Can you please split the patch to three independent parts, prefetchw >> handling, rdseed and adxx. I got lost in the patch the second time. > Sure! > >> I propose we start with prefetch. You are still changing prefetch >> patterns, while it should be enough to only change prefetch expander. > Actually, they're splitted since 3dnow has both prefetch and prefetchw > under single CPUID bit, > while under Intel's PRFTCH CPUID bit we have only prefetchw. So, old > pattern "*prefetch_3dnow_" > was set to be `prefetch` only for 3dnow, while new one is `prefetchw' only, > working both for PRFTCH and 3DNOW bits. Please see attached patch that does all this with minimum surgery and also sets missing SSE prefetch for x86_32 with -mprfchw > Changelog entry: > 2012-07-24 Kirill Yukhin > Michael Zolotukhin > > * common/config/i386/i386-common.c (OPTION_MASK_ISA_PRFCHW_SET): New. > (OPTION_MASK_ISA_PRFCHW_UNSET): Likewise. > (ix86_handle_option): Handle mprfchw option. > * config.gcc (i[34567]86-*-*): Add prfchwintrin.h. > (x86_64-*-*): Likewise. > * config/i386/prfchwintrin.h: New header. > * config/i386/cpuid.h (bit_PRFCHW): New. > (bit_BMI): Formatting fix. > (bit_HLE): Likewise. > (bit_RTM): Likewise. > * config/i386/driver-i386.c (host_detect_local_cpu): Detect > PREFETCHW support. > * config/i386/i386-c.c: Define __PRFCHW__ if needed. > * config/i386/i386.c (ix86_target_string): Define > -mprfchw option. Formatting fixes. > (PTA_HLE): Formatting fix. > (PTA_PRFCHW): New. > (ix86_option_override_internal): Handle new option. > (ix86_valid_target_attribute_inner_p): Add OPT_mprfchw. > * config/i386/i386.h (TARGET_PRFCHW): New. > * config/i386/i386.md (prefetch): Enable for TARGET_PRFCHW. > (prefetchw_): New define_insn for write-prefetch. > (prefetch_3dnow_): Keep only read-prefetch here. > * config/i386/i386.opt (mprfchw): New. > * config/i386/mm3dnow.h: Move _m_prefetchw from here to > prfchwintrin.h. > * config/i386/x86intrin.h: Include prfchwintrin.h. > > testsuite/Changelog entry: > 2012-07-24 Kirill Yukhin > Michael Zolotukhin > > * gcc.target/i386/prefetchw-1.c: New. > * gcc.target/i386/sse-12.c: Add -mprfchw. > * gcc.target/i386/sse-13.c: Ditto. > * gcc.target/i386/sse-14.c: Ditto. > * g++.dg/other/i386-2.C: Ditto. > * g++.dg/other/i386-3.C: Ditto. > > patch is bootstrapping at the moment. > > Any objections? --- /dev/null +++ b/gcc/config/i386/prfchwintrin.h +#if !defined _X86INTRIN_H_INCLUDED && !defined _MM3DNOW_H_INCLUDED +# error "Never use directly; include \ +or instead." +#endif No need to split the line. Uros. Index: i386.c =================================================================== --- i386.c (revision 189810) +++ i386.c (working copy) @@ -3647,11 +3647,12 @@ /* Turn on MMX builtins for -msse. */ if (TARGET_SSE) - { - ix86_isa_flags |= OPTION_MASK_ISA_MMX & ~ix86_isa_flags_explicit; - x86_prefetch_sse = true; - } + ix86_isa_flags |= OPTION_MASK_ISA_MMX & ~ix86_isa_flags_explicit; + /* Enable SSE prefetch. */ + if (TARGET_SSE || TARGET_PRFCHW) + x86_prefetch_sse = true; + /* Turn on popcnt instruction for -msse4.2 or -mabm. */ if (TARGET_SSE4_2 || TARGET_ABM) ix86_isa_flags |= OPTION_MASK_ISA_POPCNT & ~ix86_isa_flags_explicit; Index: i386.md =================================================================== --- i386.md (revision 189491) +++ i386.md (working copy) @@ -17684,11 +17684,13 @@ gcc_assert (GET_MODE (operands[0]) == Pmode || GET_MODE (operands[0]) == VOIDmode); + if (TARGET_PRFCHW && rw) + operands[2] = GEN_INT (3); /* Use 3dNOW prefetch in case we are asking for write prefetch not supported by SSE counterpart or the SSE prefetch is not available (K6 machines). Otherwise use SSE prefetch as it allows specifying of locality. */ - if (TARGET_3DNOW && (!TARGET_PREFETCH_SSE || rw)) + else if (TARGET_3DNOW && (!TARGET_PREFETCH_SSE || rw)) operands[2] = GEN_INT (3); else operands[1] = const0_rtx; @@ -17719,7 +17721,7 @@ [(prefetch (match_operand:P 0 "address_operand" "p") (match_operand:SI 1 "const_int_operand" "n") (const_int 3))] - "TARGET_3DNOW" + "TARGET_3DNOW || TARGET_PRFCHW" { if (INTVAL (operands[1]) == 0) return "prefetch\t%a0"; --- a/gcc/config/i386/x86intrin.h +++ b/gcc/config/i386/x86intrin.h @@ -61,6 +61,10 @@ /* For including AVX instructions */ #include +#if defined (__PRFCHW__) || defined (__3dNOW__) +#include +#endif Not needed. This header is already included through mm3dnow.h inclusion and directly below