From patchwork Sun Sep 18 09:00:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Rosen X-Patchwork-Id: 4157 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 922B823F6E for ; Sun, 18 Sep 2011 09:00:33 +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 6E51DA1832C for ; Sun, 18 Sep 2011 09:00:33 +0000 (UTC) Received: by fxe23 with SMTP id 23so4248643fxe.11 for ; Sun, 18 Sep 2011 02:00:33 -0700 (PDT) Received: by 10.223.34.143 with SMTP id l15mr2816901fad.46.1316336433249; Sun, 18 Sep 2011 02:00:33 -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.18.198 with SMTP id y6cs868lad; Sun, 18 Sep 2011 02:00:32 -0700 (PDT) Received: by 10.236.9.101 with SMTP id 65mr7150731yhs.11.1316336430651; Sun, 18 Sep 2011 02:00:30 -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 a21si13669958yhm.86.2011.09.18.02.00.28 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 18 Sep 2011 02:00:30 -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 gwj16 with SMTP id 16so5050760gwj.37 for ; Sun, 18 Sep 2011 02:00:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.150.200.18 with SMTP id x18mr1073774ybf.219.1316336428016; Sun, 18 Sep 2011 02:00:28 -0700 (PDT) Received: by 10.151.100.9 with HTTP; Sun, 18 Sep 2011 02:00:27 -0700 (PDT) Date: Sun, 18 Sep 2011 12:00:27 +0300 Message-ID: Subject: [patch] Fix PR tree-optimization/50412 From: Ira Rosen To: gcc-patches@gcc.gnu.org Cc: Patch Tracking Hi, Strided accesses of single element or with gaps may require creation of epilogue loop. At the moment we don't support peeling for outer loops, therefore, we should not allow such strided accesses in outer loops. Bootstrapped and tested on powerpc64-suse-linux. Committed to trunk. Now testing for 4.6. OK for 4.6 when the testing completes? Thanks, Ira ChangeLog: PR tree-optimization/50412 * tree-vect-data-refs.c (vect_analyze_group_access): Fail for acceses that require epilogue loop if vectorizing outer loop. testsuite/ChangeLog: PR tree-optimization/50412 * gfortran.dg/vect/pr50412.f90: New. Index: tree-vect-data-refs.c =================================================================== --- tree-vect-data-refs.c (revision 178939) +++ tree-vect-data-refs.c (working copy) @@ -2060,7 +2060,11 @@ vect_analyze_group_access (struct data_reference * HOST_WIDE_INT dr_step = TREE_INT_CST_LOW (step); HOST_WIDE_INT stride, last_accessed_element = 1; bool slp_impossible = false; + struct loop *loop = NULL; + if (loop_vinfo) + loop = LOOP_VINFO_LOOP (loop_vinfo); + /* For interleaving, STRIDE is STEP counted in elements, i.e., the size of the interleaving group (including gaps). */ stride = dr_step / type_size; @@ -2090,11 +2094,18 @@ vect_analyze_group_access (struct data_reference * if (loop_vinfo) { - LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo) = true; - if (vect_print_dump_info (REPORT_DETAILS)) fprintf (vect_dump, "Data access with gaps requires scalar " "epilogue loop"); + if (loop->inner) + { + if (vect_print_dump_info (REPORT_DETAILS)) + fprintf (vect_dump, "Peeling for outer loop is not" + " supported"); + return false; + } + + LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo) = true; } return true; @@ -2277,10 +2288,17 @@ vect_analyze_group_access (struct data_reference * /* There is a gap in the end of the group. */ if (stride - last_accessed_element > 0 && loop_vinfo) { - LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo) = true; if (vect_print_dump_info (REPORT_DETAILS)) fprintf (vect_dump, "Data access with gaps requires scalar " "epilogue loop"); + if (loop->inner) + { + if (vect_print_dump_info (REPORT_DETAILS)) + fprintf (vect_dump, "Peeling for outer loop is not supported"); + return false; + } + + LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo) = true; } } Index: testsuite/gfortran.dg/vect/pr50412.f90 =================================================================== --- testsuite/gfortran.dg/vect/pr50412.f90 (revision 0) +++ testsuite/gfortran.dg/vect/pr50412.f90 (revision 0) @@ -0,0 +1,12 @@ +! { dg-do compile } + + DOUBLE PRECISION AK,AI,AAE + COMMON/com/AK(36),AI(4,4),AAE(8,4),ii,jj + DO 20 II=1,4 + DO 21 JJ=1,4 + AK(n)=AK(n)-AAE(I,II)*AI(II,JJ) + 21 CONTINUE + 20 CONTINUE + END + +! { dg-final { cleanup-tree-dump "vect" } }