From patchwork Fri Jun 10 07:19:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Rosen X-Patchwork-Id: 1801 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.45.109) by localhost6.localdomain6 with IMAP4-SSL; 10 Jun 2011 20:11:50 -0000 Delivered-To: patches@linaro.org Received: by 10.52.181.10 with SMTP id ds10cs296013vdc; Fri, 10 Jun 2011 00:19:40 -0700 (PDT) Received: by 10.151.77.30 with SMTP id e30mr2753235ybl.269.1307690379508; Fri, 10 Jun 2011 00:19:39 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id w5si15202373icj.113.2011.06.10.00.19.38 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 10 Jun 2011 00:19:38 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of ira.rosen@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.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 pzk2 with SMTP id 2so1259433pzk.37 for ; Fri, 10 Jun 2011 00:19:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.125.18 with SMTP id x18mr298495wfc.207.1307690377240; Fri, 10 Jun 2011 00:19:37 -0700 (PDT) Received: by 10.143.93.4 with HTTP; Fri, 10 Jun 2011 00:19:37 -0700 (PDT) Date: Fri, 10 Jun 2011 10:19:37 +0300 Message-ID: Subject: [patch] Fix PR tree-optimization/49318 From: Ira Rosen To: gcc-patches@gcc.gnu.org Cc: Patch Tracking Hi, The test in PR 49318 fails because the vectorizer recognizes address computation sequence as a widening-multiplication pattern, while such sequence is not relevant to vectorization. The problem is that the vectorizer doesn't check if a statement is going to be vectorized before replacing it with a pattern. Moreover, the vectorizer first detects the patterns and only after that looks for relevant statements. Changing the order is not a good option, since statements relevance is defined also by their belonging to a pattern. This patch solves the problem by removing pattern statements that were created for statements that are not supposed to be vectorized. Bootstrapped with vectorization enabled on powerpc64-suse-linux and tested on powerpc64-suse-linux and x86_64-suse-linux. Committed. Ira ChangeLog: PR tree-optimization/49318 * tree-vect-loop.c (vect_determine_vectorization_factor): Remove irrelevant pattern statements. testsuite/ChangeLog: PR tree-optimization/49318 * gcc.dg/vect/pr49318.c: New test. Index: ChangeLog =================================================================== --- ChangeLog (revision 174889) +++ ChangeLog (working copy) @@ -1,3 +1,9 @@ +2011-06-10 Ira Rosen + + PR tree-optimization/49318 + * tree-vect-loop.c (vect_determine_vectorization_factor): Remove + irrelevant pattern statements. + 2011-06-10 Hans-Peter Nilsson * system.h (SETJMP_VIA_SAVE_AREA): Poison. Index: testsuite/gcc.dg/vect/pr49318.c =================================================================== --- testsuite/gcc.dg/vect/pr49318.c (revision 0) +++ testsuite/gcc.dg/vect/pr49318.c (revision 0) @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_float } */ + +typedef enum { GL_FALSE } GLenum; +typedef unsigned char GLboolean; +typedef int GLint; +typedef unsigned int GLuint; +typedef float GLfloat; +typedef double GLdouble; +typedef struct gl_context GLcontext; +struct gl_context { + GLfloat TextureMatrix[16]; + GLenum Primitive; +}; +void gl_GetDoublev( GLcontext *ctx, GLenum pname, GLdouble *params ) { + GLuint i; + for (i=0; i<16; i++) + params[i] = (GLint) ctx->TextureMatrix[i]; +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 174889) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2011-06-10 Ira Rosen + + PR tree-optimization/49318 + * gcc.dg/vect/pr49318.c: New test. + 2011-06-09 David Krauss * g++.dg/template/arrow1.C: New. Index: tree-vect-loop.c =================================================================== --- tree-vect-loop.c (revision 174889) +++ tree-vect-loop.c (working copy) @@ -255,10 +255,20 @@ vect_determine_vectorization_factor (loop_vec_info gcc_assert (stmt_info); - /* skip stmts which do not need to be vectorized. */ + /* Skip stmts which do not need to be vectorized. */ if (!STMT_VINFO_RELEVANT_P (stmt_info) && !STMT_VINFO_LIVE_P (stmt_info)) { + if (is_pattern_stmt_p (stmt_info)) + { + /* We are not going to vectorize this pattern statement, + therefore, remove it. */ + gimple_stmt_iterator tmp_gsi = gsi_for_stmt (stmt); + STMT_VINFO_RELATED_STMT (stmt_info) = NULL; + gsi_remove (&tmp_gsi, true); + free_stmt_vec_info (stmt); + } + if (vect_print_dump_info (REPORT_DETAILS)) fprintf (vect_dump, "skip."); continue;