From patchwork Thu Jun 10 17:04:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fang, Changpeng" X-Patchwork-Id: 55238 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 25FC91007D1 for ; Fri, 11 Jun 2010 03:07:54 +1000 (EST) Received: (qmail 26304 invoked by alias); 10 Jun 2010 17:07:50 -0000 Received: (qmail 26189 invoked by uid 22791); 10 Jun 2010 17:07:48 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from outbound-va3.frontbridge.com (HELO VA3EHSOBE009.bigfish.com) (216.32.180.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 10 Jun 2010 17:07:41 +0000 Received: from mail90-va3-R.bigfish.com (10.7.14.246) by VA3EHSOBE009.bigfish.com (10.7.40.29) with Microsoft SMTP Server id 8.1.340.0; Thu, 10 Jun 2010 17:07:39 +0000 Received: from mail90-va3 (localhost.localdomain [127.0.0.1]) by mail90-va3-R.bigfish.com (Postfix) with ESMTP id 56BEB79011E; Thu, 10 Jun 2010 17:07:39 +0000 (UTC) X-SpamScore: -15 X-BigFish: VPS-15(zz1432P9371Pzz1202hzzz32i2a8h34h61h) X-Spam-TCS-SCL: 0:0 Received: from mail90-va3 (localhost.localdomain [127.0.0.1]) by mail90-va3 (MessageSwitch) id 1276189658794512_10482; Thu, 10 Jun 2010 17:07:38 +0000 (UTC) Received: from VA3EHSMHS026.bigfish.com (unknown [10.7.14.239]) by mail90-va3.bigfish.com (Postfix) with ESMTP id B08E37E804C; Thu, 10 Jun 2010 17:07:38 +0000 (UTC) Received: from ausb3extmailp02.amd.com (163.181.251.22) by VA3EHSMHS026.bigfish.com (10.7.99.36) with Microsoft SMTP Server (TLS) id 14.0.482.44; Thu, 10 Jun 2010 17:07:30 +0000 Received: from ausb3twp02.amd.com ([163.181.250.38]) by ausb3extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with SMTP id o5AHAOLR023108; Thu, 10 Jun 2010 12:10:27 -0500 X-M-MSG: Received: from sausexhtp02.amd.com (sausexhtp02.amd.com [163.181.3.152]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by ausb3twp02.amd.com (Tumbleweed MailGate 3.7.2) with ESMTP id 212A1C86E7; Thu, 10 Jun 2010 12:07:24 -0500 (CDT) Received: from SAUSEXMBP01.amd.com ([163.181.3.198]) by sausexhtp02.amd.com ([163.181.3.152]) with mapi; Thu, 10 Jun 2010 12:07:25 -0500 From: "Fang, Changpeng" To: "Fang, Changpeng" , Zdenek Dvorak CC: "gcc-patches@gcc.gnu.org" , "sebpop@gmail.com" Date: Thu, 10 Jun 2010 12:04:53 -0500 Subject: RE: [patch, PR44297] prefetch improvements to fix 465.tonto from non-constant step prefetching Message-ID: References: <20100607231237.GL19235@codesourcery.com> , <20100609072319.GA15197@kam.mff.cuni.cz>, In-Reply-To: MIME-Version: 1.0 X-Reverse-DNS: ausb3extmailp02.amd.com 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 Forgot to ask. Is this version ok for trunk? Thanks Changpeng From bf90074c6aac420955744b7f889fca2024c31876 Mon Sep 17 00:00:00 2001 From: Changpeng Fang Date: Mon, 7 Jun 2010 14:57:27 -0700 Subject: [PATCH 2/2] Account prefetch_mod and unroll_factor for the computation of the prefetch count *tree-ssa-loop-prefetch.c (nothing_to_prefetch_p): New. Return true if no prefetch is going to be generated for a given group. (estimate_prefetch_count): Use prefetch_mod and unroll_factor to estimate the prefetch_count. (loop_prefetch_arrays): Call nothing_to_prefetch_p; estimate the prefetch count by considering the unroll_factor and prefetch_mod for is_loop_prefetching_profitable. --- gcc/tree-ssa-loop-prefetch.c | 36 +++++++++++++++++++++++++++++++----- 1 files changed, 31 insertions(+), 5 deletions(-) diff --git a/gcc/tree-ssa-loop-prefetch.c b/gcc/tree-ssa-loop-prefetch.c index d63ede1..cde5e18 100644 --- a/gcc/tree-ssa-loop-prefetch.c +++ b/gcc/tree-ssa-loop-prefetch.c @@ -987,18 +987,39 @@ schedule_prefetches (struct mem_ref_group *groups, unsigned unroll_factor, return any; } -/* Estimate the number of prefetches in the given GROUPS. */ +/* Return TRUE if no prefetch is going to be generated + in the given GROUPS. */ +static bool +nothing_to_prefetch_p (struct mem_ref_group *groups) +{ + struct mem_ref *ref; + + for (; groups; groups = groups->next) + for (ref = groups->refs; ref; ref = ref->next) + if (should_issue_prefetch_p (ref)) + return false; + + return true; +} + +/* Estimate the number of prefetches in the given GROUPS. + UNROLL_FACTOR is the factor by which LOOP was unrolled. */ static int -estimate_prefetch_count (struct mem_ref_group *groups) +estimate_prefetch_count (struct mem_ref_group *groups, unsigned unroll_factor) { struct mem_ref *ref; + unsigned n_prefetches; int prefetch_count = 0; for (; groups; groups = groups->next) for (ref = groups->refs; ref; ref = ref->next) if (should_issue_prefetch_p (ref)) - prefetch_count++; + { + n_prefetches = ((unroll_factor + ref->prefetch_mod - 1) + / ref->prefetch_mod); + prefetch_count += n_prefetches; + } return prefetch_count; } @@ -1709,8 +1730,7 @@ loop_prefetch_arrays (struct loop *loop) /* Step 2: estimate the reuse effects. */ prune_by_reuse (refs); - prefetch_count = estimate_prefetch_count (refs); - if (prefetch_count == 0) + if (nothing_to_prefetch_p (refs)) goto fail; determine_loop_nest_reuse (loop, refs, no_other_refs); @@ -1726,6 +1746,12 @@ loop_prefetch_arrays (struct loop *loop) ninsns = tree_num_loop_insns (loop, &eni_size_weights); unroll_factor = determine_unroll_factor (loop, refs, ninsns, &desc, est_niter); + + /* Estimate prefetch count for the unrolled loop. */ + prefetch_count = estimate_prefetch_count (refs, unroll_factor); + if (prefetch_count == 0) + goto fail; + if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Ahead %d, unroll factor %d, trip count " HOST_WIDE_INT_PRINT_DEC "\n" -- 1.6.3.3