From patchwork Sun Jul 3 10:04:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Rosen X-Patchwork-Id: 103004 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 84F57B6F62 for ; Sun, 3 Jul 2011 20:04:35 +1000 (EST) Received: (qmail 8853 invoked by alias); 3 Jul 2011 10:04:31 -0000 Received: (qmail 8845 invoked by uid 22791); 3 Jul 2011 10:04:30 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL, BAYES_00, TW_TM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mtagate3.uk.ibm.com (HELO mtagate3.uk.ibm.com) (194.196.100.163) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 03 Jul 2011 10:04:16 +0000 Received: from d06nrmr1806.portsmouth.uk.ibm.com (d06nrmr1806.portsmouth.uk.ibm.com [9.149.39.193]) by mtagate3.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p63A4CGU004981 for ; Sun, 3 Jul 2011 10:04:12 GMT Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p63A4C8v2625676 for ; Sun, 3 Jul 2011 11:04:12 +0100 Received: from d06av07.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p63A4BZi003865 for ; Sun, 3 Jul 2011 04:04:11 -0600 Received: from d12mc102.megacenter.de.ibm.com (d12mc102.megacenter.de.ibm.com [9.149.167.114]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p63A4B0A003862; Sun, 3 Jul 2011 04:04:11 -0600 In-Reply-To: References: Subject: Re: [PATCH] Handle vectorization of invariant loads (PR46787) X-KeepSent: 9AFE9E37:ACAD8F40-C22578C2:003681D5; type=4; name=$KeepSent To: Richard Guenther Cc: gcc-patches@gcc.gnu.org Message-ID: From: Ira Rosen Date: Sun, 3 Jul 2011 13:04:09 +0300 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Richard Guenther wrote on 30/06/2011 06:24:50 PM: > FYI, I'm testing the following which cures a fallout seen when > building SPEC2k6 with the committed patch. It's suboptimal for > j != 0 though - is there a way to get to the vectorized stmt > of the j == 0 iteration? Yes, I think we can simply use the stmt from the previous iteration, but we have to avoid creation of unnecessary vector loads. Even though multiple uses of that single load are still created, they are cleaned up later. (I didn't indent the code properly and only tested the patch on the vectorizer testsuite). Ira offset, &dummy, gsi, @@ -4393,11 +4395,11 @@ vectorizable_load (gimple stmt, gimple_s else dataref_ptr = bump_vector_ptr (dataref_ptr, ptr_incr, gsi, stmt, TYPE_SIZE_UNIT (aggr_type)); - + } if (strided_load || slp_perm) dr_chain = VEC_alloc (tree, heap, vec_num); - if (load_lanes_p) + if (load_lanes_p && (!inv_p || bb_vinfo)) { tree vec_array; @@ -4426,6 +4428,8 @@ vectorizable_load (gimple stmt, gimple_s { for (i = 0; i < vec_num; i++) { + if (!inv_p || bb_vinfo) + { if (i > 0) dataref_ptr = bump_vector_ptr (dataref_ptr, ptr_incr, gsi, stmt, NULL_TREE); @@ -4570,18 +4574,22 @@ vectorizable_load (gimple stmt, gimple_s msq = lsq; } } - + } + /* 4. Handle invariant-load. */ - if (inv_p && !bb_vinfo) - { - tree vec_inv; - gimple_stmt_iterator gsi2 = *gsi; - gcc_assert (!strided_load); - gsi_next (&gsi2); - vec_inv = build_vector_from_val (vectype, scalar_dest); - new_temp = vect_init_vector (stmt, vec_inv, - vectype, &gsi2); - new_stmt = SSA_NAME_DEF_STMT (new_temp); + else + { + if (j==0) + { + tree vec_inv; + gimple_stmt_iterator gsi2 = *gsi; + gcc_assert (!strided_load); + gsi_next (&gsi2); + vec_inv = build_vector_from_val (vectype, scalar_dest); + new_temp = vect_init_vector (stmt, vec_inv, + vectype, &gsi2); + new_stmt = SSA_NAME_DEF_STMT (new_temp); + } } if (negative) > > Thanks, > Richard. > > 2011-06-30 Richard Guenther > > * tree-vect-stmts.c (vectorizable_load): Remove unnecessary > assert. > > Index: gcc/tree-vect-stmts.c > =================================================================== > --- gcc/tree-vect-stmts.c (revision 175709) > +++ gcc/tree-vect-stmts.c (working copy) > @@ -4574,19 +4574,14 @@ vectorizable_load (gimple stmt, gimple_s > /* 4. Handle invariant-load. */ > if (inv_p && !bb_vinfo) > { > + tree vec_inv; > + gimple_stmt_iterator gsi2 = *gsi; > gcc_assert (!strided_load); > - if (j == 0) > - { > - tree vec_inv; > - gimple_stmt_iterator gsi2 = *gsi; > - gsi_next (&gsi2); > - vec_inv = build_vector_from_val (vectype, scalar_dest); > - new_temp = vect_init_vector (stmt, vec_inv, > - vectype, &gsi2); > - new_stmt = SSA_NAME_DEF_STMT (new_temp); > - } > - else > - gcc_unreachable (); /* FORNOW. */ > + gsi_next (&gsi2); > + vec_inv = build_vector_from_val (vectype, scalar_dest); > + new_temp = vect_init_vector (stmt, vec_inv, > + vectype, &gsi2); > + new_stmt = SSA_NAME_DEF_STMT (new_temp); > } > > if (negative) Index: tree-vect-stmts.c =================================================================== --- tree-vect-stmts.c (revision 175785) +++ tree-vect-stmts.c (working copy) @@ -4386,6 +4386,8 @@ vectorizable_load (gimple stmt, gimple_s for (j = 0; j < ncopies; j++) { /* 1. Create the vector or array pointer update chain. */ + if (!inv_p || bb_vinfo) + { if (j == 0) dataref_ptr = vect_create_data_ref_ptr (first_stmt, aggr_type, at_loop,