From patchwork Tue Mar 29 10:27:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Rosen X-Patchwork-Id: 821 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:46:09 -0000 Delivered-To: patches@linaro.org Received: by 10.42.161.68 with SMTP id s4cs174814icx; Tue, 29 Mar 2011 03:27:09 -0700 (PDT) Received: by 10.213.28.10 with SMTP id k10mr2345536ebc.24.1301394428281; Tue, 29 Mar 2011 03:27:08 -0700 (PDT) Received: from mtagate1.uk.ibm.com (mtagate1.uk.ibm.com [194.196.100.161]) by mx.google.com with ESMTPS id a11si8348626wer.104.2011.03.29.03.27.07 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 29 Mar 2011 03:27:08 -0700 (PDT) Received-SPF: pass (google.com: domain of IRAR@il.ibm.com designates 194.196.100.161 as permitted sender) client-ip=194.196.100.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of IRAR@il.ibm.com designates 194.196.100.161 as permitted sender) smtp.mail=IRAR@il.ibm.com Received: from d06nrmr1507.portsmouth.uk.ibm.com (d06nrmr1507.portsmouth.uk.ibm.com [9.149.38.233]) by mtagate1.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p2TAR71B002677 for ; Tue, 29 Mar 2011 10:27:07 GMT Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p2TARegh1630440 for ; Tue, 29 Mar 2011 11:27:40 +0100 Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p2TAR65Z029250 for ; Tue, 29 Mar 2011 04:27:06 -0600 Received: from d12mc102.megacenter.de.ibm.com (d12nrml1506.megacenter.de.ibm.com [9.149.165.56] (may be forged)) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p2TAR6BB029247; Tue, 29 Mar 2011 04:27:06 -0600 Subject: [patch] Fix PR tree-optmization/48290 X-KeepSent: 5DF5ADD6:92673DA4-C2257862:00359478; type=4; name=$KeepSent To: gcc-patches@gcc.gnu.org Cc: patches@linaro.org X-Mailer: Lotus Notes Release 8.5 HF58 February 06, 2009 Message-ID: From: Ira Rosen Date: Tue, 29 Mar 2011 13:27:02 +0300 X-MIMETrack: Serialize by Router on D12MC102/12/M/IBM(Release 8.5.1FP4|July 25, 2010) at 29/03/2011 13:27:11 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Hi, This patch fixes the vectorizer part of PR tree-optmization/48290 by checking that if we have a phi in outer loop in the basic block after the inner loop, then this phi is really inner loop's exit phi, i.e., its operand is defined in the inner loop. Bootstrapped with vectorization enabled on powerpc64-suse-linux and tested on x86_64-suse-linux. Committed. Ira ChangeLog: PR tree-optimization/48290 * tree-vect-loop.c (vect_analyze_loop_operations): In outer loop vectorization, check that relevant phis in the basic block after the inner loop are really inner loop's exit phis. are not used in the outerloop (unless it is double reduction, i.e., this phi is vect_reduction_def), cause this case requires to actually do something here. */ @@ -1202,6 +1202,32 @@ vect_analyze_loop_operations (loop_vec_info loop_v "Unsupported loop-closed phi in outer-loop."); return false; } + + /* If PHI is used in the outer loop, we check that its operand + is defined in the inner loop. */ + if (STMT_VINFO_RELEVANT_P (stmt_info)) + { + tree phi_op; + gimple op_def_stmt; + + if (gimple_phi_num_args (phi) != 1) + return false; + + phi_op = PHI_ARG_DEF (phi, 0); + if (TREE_CODE (phi_op) != SSA_NAME) + return false; + + op_def_stmt = SSA_NAME_DEF_STMT (phi_op); + if (!op_def_stmt || !vinfo_for_stmt (op_def_stmt)) + return false; + + if (STMT_VINFO_RELEVANT (vinfo_for_stmt (op_def_stmt)) + != vect_used_in_outer + && STMT_VINFO_RELEVANT (vinfo_for_stmt (op_def_stmt)) + != vect_used_in_outer_by_reduction) + return false; + } + continue; } Index: tree-vect-loop.c =================================================================== --- tree-vect-loop.c (revision 171654) +++ tree-vect-loop.c (working copy) @@ -1184,11 +1184,11 @@ vect_analyze_loop_operations (loop_vec_info loop_v print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM); } + /* Inner-loop loop-closed exit phi in outer-loop vectorization + (i.e., a phi in the tail of the outer-loop). */ if (! is_loop_header_bb_p (bb)) { - /* inner-loop loop-closed exit phi in outer-loop vectorization - (i.e. a phi in the tail of the outer-loop). - FORNOW: we currently don't support the case that these phis + /* FORNOW: we currently don't support the case that these phis