From patchwork Tue May 31 12:31:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Rosen X-Patchwork-Id: 1679 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:54:19 -0000 Delivered-To: patches@linaro.org Received: by 10.52.110.9 with SMTP id hw9cs287733vdb; Tue, 31 May 2011 05:31:27 -0700 (PDT) Received: by 10.224.203.135 with SMTP id fi7mr1845413qab.348.1306845086776; Tue, 31 May 2011 05:31:26 -0700 (PDT) Received: from mail-qy0-f171.google.com (mail-qy0-f171.google.com [209.85.216.171]) by mx.google.com with ESMTPS id s1si50826qco.9.2011.05.31.05.31.25 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 31 May 2011 05:31:25 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.216.171 is neither permitted nor denied by best guess record for domain of ira.rosen@linaro.org) client-ip=209.85.216.171; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.216.171 is neither permitted nor denied by best guess record for domain of ira.rosen@linaro.org) smtp.mail=ira.rosen@linaro.org Received: by qyj19 with SMTP id 19so1420926qyj.16 for ; Tue, 31 May 2011 05:31:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.224.205.132 with SMTP id fq4mr3898048qab.242.1306845085483; Tue, 31 May 2011 05:31:25 -0700 (PDT) Received: by 10.224.60.74 with HTTP; Tue, 31 May 2011 05:31:25 -0700 (PDT) Date: Tue, 31 May 2011 15:31:25 +0300 Message-ID: Subject: [patch] Fix PR tree-optimization/49093 From: Ira Rosen To: gcc-patches@gcc.gnu.org Cc: Patch Tracking Hi, This patch fails vectorization for volatile data references. Bootstrapped on powerpc64-suse-linux and tested on powerpc64-suse-linux and x86_64-suse-linux. Applied to trunk. OK for 4.6 after testing? Thanks, Ira ChangeLog: PR tree-optimization/49093 * tree-vect-data-refs.c (vect_analyze_data_refs): Fail for volatile data references. testsuite/ChangeLog: PR tree-optimization/49093 * gcc.dg/vect/pr49093.c: New test. Index: testsuite/gcc.dg/vect/pr49093.c =================================================================== --- testsuite/gcc.dg/vect/pr49093.c (revision 0) +++ testsuite/gcc.dg/vect/pr49093.c (revision 0) @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftree-vectorize -fdump-tree-vect-details -fno-tree-fre" } */ + +volatile unsigned char g_324[4] = {0, 1, 0, 1}; +void foo (int); +int x, y; +void func_81(void) +{ + int l_466, l_439[7] = {0}, g_97; +lbl_473: + if (x) { + for (g_97 = 0; (g_97 < 4); ++g_97) { + if (y) + goto lbl_473; + g_324[g_97]; + l_466 = l_439[g_97]; + } + foo(l_466); + } +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ Index: tree-vect-data-refs.c =================================================================== --- tree-vect-data-refs.c (revision 174471) +++ tree-vect-data-refs.c (working copy) @@ -2584,6 +2584,16 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, return false; } + if (TREE_THIS_VOLATILE (DR_REF (dr))) + { + if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS)) + { + fprintf (vect_dump, "not vectorized: volatile type "); + print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM); + } + return false; + } + base = unshare_expr (DR_BASE_ADDRESS (dr)); offset = unshare_expr (DR_OFFSET (dr)); init = unshare_expr (DR_INIT (dr));