From patchwork Sat Apr 7 17:53:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Endo X-Patchwork-Id: 151309 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 487B1B70A0 for ; Sun, 8 Apr 2012 03:54:01 +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=1334426042; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Subject:From:To:Content-Type:Date:Message-ID:Mime-Version: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=oeTRFep82BDtJpJjJYxC HPXKG10=; b=bKNmu9d6pBHU3ztdtDOYXpu0KF6qvpNi8a3dvo/6UNmnrQBIm9Pp H6Z2qL4TPaH87rdbQJdUIMoLrTHDimovsoUhQePjjotKm2dXYU3Ng1jty9XA0ULy j5XhGHXlpCCEisDrGuUt3wkNhthwRaG8sM3pqceW+rgvsb+tD8kfvRE= 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:Received:Subject:From:To:Content-Type:Date:Message-ID:Mime-Version:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=dSZm0kY/3OeGeihMS4RV/h2F2vDfgsrXcYGSVSCvQDVLExoDqbL++LwfRknVUE USgYBaxVUShIBY4cZIJV2SmhBol3VjHguEN0RTJk6s184jhR/x7UPSC+YJHaGU8I BF2JLrRhbvZtTfvF1tHHwOnt+cuRGQkZjqEhv1O+pivkE=; Received: (qmail 2968 invoked by alias); 7 Apr 2012 17:53:56 -0000 Received: (qmail 2960 invoked by uid 22791); 7 Apr 2012 17:53:55 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_NO, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Received: from mailout11.t-online.de (HELO mailout11.t-online.de) (194.25.134.85) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 07 Apr 2012 17:53:38 +0000 Received: from fwd25.aul.t-online.de (fwd25.aul.t-online.de ) by mailout11.t-online.de with smtp id 1SGZpR-0000zC-0Z; Sat, 07 Apr 2012 19:53:37 +0200 Received: from [192.168.0.104] (Gv1qVTZ-Qhp7GgHSDYVDPxstkJPlwAzvPVG3zhQBy5DysZAWLZpR5ebOxpxC64sQnY@[87.157.46.153]) by fwd25.t-online.de with esmtp id 1SGZpF-0IkLjM0; Sat, 7 Apr 2012 19:53:25 +0200 Subject: [SH] Fold prefetch insns From: Oleg Endo To: gcc-patches Date: Sat, 07 Apr 2012 19:53:15 +0200 Message-ID: <1333821195.19154.94.camel@yam-132-YW-E178-FTW> Mime-Version: 1.0 X-IsSubscribed: yes 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 Hi, The attached patch folds the prefetch insns for SH4 and SH2A. As far as I can see, there is no need to have two of them. The patch also adapts the sh2a-prefetch test case to be ran for SH4, too. Tested by running said test case with make check-gcc RUNTESTFLAGS="sh.exp=prefetch* --target_board=sh-sim \{-m2/-ml,-m2/-mb,-m2a/-mb,-m2a-single/-mb,-m4/-ml,-m4/-mb, -m4-single/-ml,-m4-single/-mb,-m4a-single/-ml,-m4a-single/-mb}" OK? Cheers, Oleg ChangeLog: * config/sh/sh.md (*prefetch_i4, prefetch_m2a): Merge into ... (*prefetch): ... this new insn. testsuite/ChangeLog: * gcc.target/sh/sh2a-prefetch.c: Rename to ... * gcc.target/sh/prefetch.c: ... this. Enable test case for m4*. Index: gcc/testsuite/gcc.target/sh/prefetch.c =================================================================== --- gcc/testsuite/gcc.target/sh/prefetch.c (revision 0) +++ gcc/testsuite/gcc.target/sh/prefetch.c (revision 0) @@ -0,0 +1,35 @@ +/* Testcase to check generation of a SH4 and SH2A operand cache prefetch + instruction PREF @Rm. */ +/* { dg-do assemble {target sh*-*-*}} */ +/* { dg-options "-O0" } */ +/* { dg-skip-if "" { "sh*-*-*" } { "*" } { "-m2a*" "-m4*" } } */ +/* { dg-final { scan-assembler "pref"} } */ + +void +opt (void) +{ + int *p, wk; + int data[100]; + + /* data prefetch , instructions hit the cache. */ + + __builtin_prefetch (&data[0], 0, 0); + __builtin_prefetch (&data[0], 0, 1); + __builtin_prefetch (&data[0], 0, 2); + __builtin_prefetch (&data[0], 0, 3); + __builtin_prefetch (&data[0], 1, 0); + __builtin_prefetch (&data[0], 1, 1); + __builtin_prefetch (&data[0], 1, 2); + __builtin_prefetch (&data[0], 1, 3); + + + for (p = &data[0]; p < &data[9]; p++) + { + if (*p > *(p + 1)) + { + wk = *p; + *p = *(p + 1); + *(p + 1) = wk; + } + } +} Index: gcc/testsuite/gcc.target/sh/sh2a-prefetch.c =================================================================== --- gcc/testsuite/gcc.target/sh/sh2a-prefetch.c (revision 186209) +++ gcc/testsuite/gcc.target/sh/sh2a-prefetch.c (working copy) @@ -1,34 +0,0 @@ -/* Testcase to check generation of a SH2A specific instruction PREF @Rm. */ -/* { dg-do assemble {target sh*-*-*}} */ -/* { dg-options "-O0" } */ -/* { dg-skip-if "" { "sh*-*-*" } "*" "-m2a -m2a-nofpu -m2a-single -m2a-single-only" } */ -/* { dg-final { scan-assembler "pref"} } */ - -void -opt (void) -{ - int *p, wk; - int data[100]; - - /* data prefetch , instructions hit the cache. */ - - __builtin_prefetch (&data[0], 0, 0); - __builtin_prefetch (&data[0], 0, 1); - __builtin_prefetch (&data[0], 0, 2); - __builtin_prefetch (&data[0], 0, 3); - __builtin_prefetch (&data[0], 1, 0); - __builtin_prefetch (&data[0], 1, 1); - __builtin_prefetch (&data[0], 1, 2); - __builtin_prefetch (&data[0], 1, 3); - - - for (p = &data[0]; p < &data[9]; p++) - { - if (*p > *(p + 1)) - { - wk = *p; - *p = *(p + 1); - *(p + 1) = wk; - } - } -} Index: gcc/config/sh/sh.md =================================================================== --- gcc/config/sh/sh.md (revision 186212) +++ gcc/config/sh/sh.md (working copy) @@ -13559,14 +13559,6 @@ } [(set_attr "type" "other")]) -(define_insn "*prefetch_i4" - [(prefetch (match_operand:SI 0 "register_operand" "r") - (match_operand:SI 1 "const_int_operand" "n") - (match_operand:SI 2 "const_int_operand" "n"))] - "(TARGET_HARD_SH4 || TARGET_SHCOMPACT) && !TARGET_VXWORKS_RTP" - "pref @%0"; - [(set_attr "type" "other")]) - ;; In user mode, the "pref" instruction will raise a RADDERR exception ;; for accesses to [0x80000000,0xffffffff]. This makes it an unsuitable ;; implementation of __builtin_prefetch for VxWorks RTPs. @@ -13585,12 +13577,12 @@ operands[0] = force_reg (Pmode, operands[0]); }) -(define_insn "prefetch_m2a" +(define_insn "*prefetch" [(prefetch (match_operand:SI 0 "register_operand" "r") (match_operand:SI 1 "const_int_operand" "n") (match_operand:SI 2 "const_int_operand" "n"))] - "TARGET_SH2A" - "pref\\t@%0" + "(TARGET_SH2A || TARGET_HARD_SH4 || TARGET_SHCOMPACT) && !TARGET_VXWORKS_RTP" + "pref @%0" [(set_attr "type" "other")]) (define_insn "alloco_i"