From patchwork Sun Sep 25 09:24:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Rosen X-Patchwork-Id: 4314 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 1B3DD23EFB for ; Sun, 25 Sep 2011 09:24:24 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 03CBCA187F6 for ; Sun, 25 Sep 2011 09:24:24 +0000 (UTC) Received: by fxe23 with SMTP id 23so7067780fxe.11 for ; Sun, 25 Sep 2011 02:24:23 -0700 (PDT) Received: by 10.223.45.140 with SMTP id e12mr1540748faf.27.1316942663812; Sun, 25 Sep 2011 02:24:23 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.3.234 with SMTP id f10cs5389laf; Sun, 25 Sep 2011 02:24:22 -0700 (PDT) Received: by 10.236.128.161 with SMTP id f21mr31993227yhi.67.1316942660922; Sun, 25 Sep 2011 02:24:20 -0700 (PDT) Received: from mail-gw0-f50.google.com (mail-gw0-f50.google.com [74.125.83.50]) by mx.google.com with ESMTPS id q42si1030453yhm.144.2011.09.25.02.24.19 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 25 Sep 2011 02:24:20 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.50 is neither permitted nor denied by best guess record for domain of ira.rosen@linaro.org) client-ip=74.125.83.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.83.50 is neither permitted nor denied by best guess record for domain of ira.rosen@linaro.org) smtp.mail=ira.rosen@linaro.org Received: by gwj19 with SMTP id 19so3620452gwj.37 for ; Sun, 25 Sep 2011 02:24:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.150.65.13 with SMTP id n13mr5263147yba.293.1316942659155; Sun, 25 Sep 2011 02:24:19 -0700 (PDT) Received: by 10.151.113.18 with HTTP; Sun, 25 Sep 2011 02:24:19 -0700 (PDT) In-Reply-To: References: Date: Sun, 25 Sep 2011 12:24:19 +0300 Message-ID: Subject: Re: [patch] Allow not simple ivs in SLP From: Ira Rosen To: Richard Guenther Cc: gcc-patches@gcc.gnu.org, Patch Tracking On 23 September 2011 23:09, Richard Guenther wrote: > On Wed, Sep 14, 2011 at 2:01 PM, Ira Rosen wrote: >> Hi, >> >> This patch makes data-refs analysis to not fail if simple_iv returns >> false in basic block SLP. >> >> Bootstrapped and tested on powerpc64-suse-linux. >> OK for mainline? > > Ok if you instead of wrapping dr_analyze_innermost change the remaining > callers to pass the loop nest parameter instead. I committed the attached patch. Thanks, Ira > > Thanks, > Richard. > Index: tree-loop-distribution.c =================================================================== --- tree-loop-distribution.c (revision 179159) +++ tree-loop-distribution.c (working copy) @@ -268,7 +268,7 @@ generate_memset_zero (gimple stmt, tree op0, tree DR_STMT (dr) = stmt; DR_REF (dr) = op0; - res = dr_analyze_innermost (dr); + res = dr_analyze_innermost (dr, loop_containing_stmt (stmt)); gcc_assert (res && stride_of_unit_type_p (DR_STEP (dr), TREE_TYPE (op0))); nb_bytes = build_size_arg_loc (loc, nb_iter, op0, &stmt_list); Index: ChangeLog =================================================================== --- ChangeLog (revision 179159) +++ ChangeLog (working copy) @@ -1,3 +1,13 @@ +2011-09-25 Ira Rosen + + * tree-data-ref.c (dr_analyze_innermost): Add new argument. + Allow not simple iv if analyzing basic block. + (create_data_ref): Update call to dr_analyze_innermost. + (stmt_with_adjacent_zero_store_dr_p, ref_base_address): Likewise. + * tree-loop-distribution.c (generate_memset_zero): Likewise. + * tree-predcom.c (find_looparound_phi): Likewise. + * tree-data-ref.h (dr_analyze_innermost): Add new argument. + 2011-09-24 David S. Miller * config/sparc/sparc.h (FIRST_PSEUDO_REGISTER): Bump to 103. Index: testsuite/gcc.dg/vect/bb-slp-24.c =================================================================== --- testsuite/gcc.dg/vect/bb-slp-24.c (revision 0) +++ testsuite/gcc.dg/vect/bb-slp-24.c (revision 0) @@ -0,0 +1,59 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define A 3 +#define N 256 + +short src[N], dst[N]; + +void foo (short * __restrict__ dst, short * __restrict__ src, int h, + int stride, int dummy) +{ + int i; + h /= 8; + for (i = 0; i < h; i++) + { + dst[0] += A*src[0]; + dst[1] += A*src[1]; + dst[2] += A*src[2]; + dst[3] += A*src[3]; + dst[4] += A*src[4]; + dst[5] += A*src[5]; + dst[6] += A*src[6]; + dst[7] += A*src[7]; + dst += stride; + src += stride; + if (dummy == 32) + abort (); + } +} + + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + dst[i] = 0; + src[i] = i; + } + + foo (dst, src, N, 8, 0); + + for (i = 0; i < N; i++) + { + if (dst[i] != A * i) + abort (); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "basic block vectorized using SLP" 1 "slp" { target vect_element_align } } } */ +/* { dg-final { cleanup-tree-dump "slp" } } */ + Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 179159) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,7 @@ +2011-09-25 Ira Rosen + + * gcc.dg/vect/bb-slp-24.c: New. + 2011-09-24 Jason Merrill * g++.dg/cpp0x/nsdmi-eh1.C: New. Index: tree-data-ref.c =================================================================== --- tree-data-ref.c (revision 179159) +++ tree-data-ref.c (working copy) @@ -722,11 +722,11 @@ canonicalize_base_object_address (tree addr) } /* Analyzes the behavior of the memory reference DR in the innermost loop or - basic block that contains it. Returns true if analysis succeed or false + basic block that contains it. Returns true if analysis succeed or false otherwise. */ bool -dr_analyze_innermost (struct data_reference *dr) +dr_analyze_innermost (struct data_reference *dr, struct loop *nest) { gimple stmt = DR_STMT (dr); struct loop *loop = loop_containing_stmt (stmt); @@ -769,14 +769,25 @@ bool } else base = build_fold_addr_expr (base); + if (in_loop) { if (!simple_iv (loop, loop_containing_stmt (stmt), base, &base_iv, false)) { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, "failed: evolution of base is not affine.\n"); - return false; + if (nest) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, "failed: evolution of base is not" + " affine.\n"); + return false; + } + else + { + base_iv.base = base; + base_iv.step = ssize_int (0); + base_iv.no_overflow = true; + } } } else @@ -801,10 +812,18 @@ bool else if (!simple_iv (loop, loop_containing_stmt (stmt), poffset, &offset_iv, false)) { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, "failed: evolution of offset is not" - " affine.\n"); - return false; + if (nest) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, "failed: evolution of offset is not" + " affine.\n"); + return false; + } + else + { + offset_iv.base = poffset; + offset_iv.step = ssize_int (0); + } } } @@ -972,7 +991,7 @@ create_data_ref (loop_p nest, loop_p loop, tree me DR_REF (dr) = memref; DR_IS_READ (dr) = is_read; - dr_analyze_innermost (dr); + dr_analyze_innermost (dr, nest); dr_analyze_indices (dr, nest, loop); dr_analyze_alias (dr); @@ -5150,7 +5169,7 @@ stmt_with_adjacent_zero_store_dr_p (gimple stmt) DR_STMT (dr) = stmt; DR_REF (dr) = op0; - res = dr_analyze_innermost (dr) + res = dr_analyze_innermost (dr, loop_containing_stmt (stmt)) && stride_of_unit_type_p (DR_STEP (dr), TREE_TYPE (op0)); free_data_ref (dr); @@ -5190,7 +5209,7 @@ ref_base_address (gimple stmt, data_ref_loc *ref) DR_STMT (dr) = stmt; DR_REF (dr) = *ref->pos; - dr_analyze_innermost (dr); + dr_analyze_innermost (dr, loop_containing_stmt (stmt)); base_address = DR_BASE_ADDRESS (dr); if (!base_address) Index: tree-data-ref.h =================================================================== --- tree-data-ref.h (revision 179159) +++ tree-data-ref.h (working copy) @@ -386,7 +386,7 @@ DEF_VEC_O (data_ref_loc); DEF_VEC_ALLOC_O (data_ref_loc, heap); bool get_references_in_stmt (gimple, VEC (data_ref_loc, heap) **); -bool dr_analyze_innermost (struct data_reference *); +bool dr_analyze_innermost (struct data_reference *, struct loop *); extern bool compute_data_dependences_for_loop (struct loop *, bool, VEC (loop_p, heap) **, VEC (data_reference_p, heap) **, Index: tree-predcom.c =================================================================== --- tree-predcom.c (revision 179159) +++ tree-predcom.c (working copy) @@ -1116,7 +1116,7 @@ find_looparound_phi (struct loop *loop, dref ref, memset (&init_dr, 0, sizeof (struct data_reference)); DR_REF (&init_dr) = init_ref; DR_STMT (&init_dr) = phi; - if (!dr_analyze_innermost (&init_dr)) + if (!dr_analyze_innermost (&init_dr, loop)) return NULL; if (!valid_initializer_p (&init_dr, ref->distance + 1, root->ref))