From patchwork Thu Sep 15 10:47:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Rosen X-Patchwork-Id: 4089 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 9865823EF8 for ; Thu, 15 Sep 2011 10:47:35 +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 83A96A1800A for ; Thu, 15 Sep 2011 10:47:35 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id 23so684311fxe.11 for ; Thu, 15 Sep 2011 03:47:35 -0700 (PDT) Received: by 10.223.5.76 with SMTP id 12mr670855fau.103.1316083625238; Thu, 15 Sep 2011 03:47:05 -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.11.8 with SMTP id m8cs87691lab; Thu, 15 Sep 2011 03:47:05 -0700 (PDT) Received: by 10.236.190.200 with SMTP id e48mr5385288yhn.59.1316083624029; Thu, 15 Sep 2011 03:47:04 -0700 (PDT) Received: from mail-yw0-f50.google.com (mail-yw0-f50.google.com [209.85.213.50]) by mx.google.com with ESMTPS id i3si3415375yhk.94.2011.09.15.03.47.03 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 15 Sep 2011 03:47:04 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.213.50 is neither permitted nor denied by best guess record for domain of ira.rosen@linaro.org) client-ip=209.85.213.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.213.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 ywm13 with SMTP id 13so2299066ywm.37 for ; Thu, 15 Sep 2011 03:47:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.150.244.7 with SMTP id r7mr1056338ybh.390.1316083623390; Thu, 15 Sep 2011 03:47:03 -0700 (PDT) Received: by 10.150.96.18 with HTTP; Thu, 15 Sep 2011 03:47:03 -0700 (PDT) Date: Thu, 15 Sep 2011 13:47:03 +0300 Message-ID: Subject: [patch] Allow read-after-read dependence in basic block SLP From: Ira Rosen To: gcc-patches@gcc.gnu.org Cc: Patch Tracking Bootstrapped and tested on powerpc64-suse-linux. Committed to trunk. Ira ChangeLog: * tree-vect-data-refs.c (vect_analyze_data_ref_dependence): Allow read-after-read dependencies in basic block SLP. testsuite/ChangeLog: * gcc.dg/vect/bb-slp-25.c: New. + Index: tree-vect-data-refs.c =================================================================== --- tree-vect-data-refs.c (revision 178879) +++ tree-vect-data-refs.c (working copy) @@ -607,6 +607,11 @@ vect_analyze_data_ref_dependence (struct data_depe if (vect_check_interleaving (dra, drb)) return false; + /* Read-read is OK (we need this check here, after checking for + interleaving). */ + if (DR_IS_READ (dra) && DR_IS_READ (drb)) + return false; + if (vect_print_dump_info (REPORT_DR_DETAILS)) { fprintf (vect_dump, "can't determine dependence between "); Index: testsuite/gcc.dg/vect/bb-slp-25.c =================================================================== --- testsuite/gcc.dg/vect/bb-slp-25.c (revision 0) +++ testsuite/gcc.dg/vect/bb-slp-25.c (revision 0) @@ -0,0 +1,57 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define A 3 +#define B 4 +#define N 256 + +short src[N], dst[N]; + +void foo (short * __restrict dst, short * __restrict src, int h, int stride) +{ + int i; + h /= 16; + for (i = 0; i < h; i++) + { + dst[0] += A*src[0] + src[stride]; + dst[1] += A*src[1] + src[1+stride]; + dst[2] += A*src[2] + src[2+stride]; + dst[3] += A*src[3] + src[3+stride]; + dst[4] += A*src[4] + src[4+stride]; + dst[5] += A*src[5] + src[5+stride]; + dst[6] += A*src[6] + src[6+stride]; + dst[7] += A*src[7] + src[7+stride]; + dst += 8; + src += 8; + } +} + + +int main (void) +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + dst[i] = 0; + src[i] = i; + } + + foo (dst, src, N, 8); + + for (i = 0; i < N/2; i++) + { + if (dst[i] != A * i + i + 8) + 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" } } */