From patchwork Tue Apr 12 13:09:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 976 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:47:54 -0000 Delivered-To: patches@linaro.org Received: by 10.68.59.138 with SMTP id z10cs178170pbq; Tue, 12 Apr 2011 06:09:59 -0700 (PDT) Received: by 10.227.130.203 with SMTP id u11mr6462897wbs.219.1302613798251; Tue, 12 Apr 2011 06:09:58 -0700 (PDT) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx.google.com with ESMTPS id m1si10362409wbc.46.2011.04.12.06.09.57 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Apr 2011 06:09:58 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of richard.sandiford@linaro.org) client-ip=74.125.82.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of richard.sandiford@linaro.org) smtp.mail=richard.sandiford@linaro.org Received: by wwc33 with SMTP id 33so7426119wwc.31 for ; Tue, 12 Apr 2011 06:09:57 -0700 (PDT) Received: by 10.227.110.37 with SMTP id l37mr848733wbp.114.1302613797317; Tue, 12 Apr 2011 06:09:57 -0700 (PDT) Received: from richards-thinkpad (gbibp9ph1--blueice2n1.emea.ibm.com [195.212.29.75]) by mx.google.com with ESMTPS id b20sm4027322wbb.50.2011.04.12.06.09.56 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Apr 2011 06:09:56 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, patches@linaro.org, richard.sandiford@linaro.org Cc: patches@linaro.org Subject: Tidy dr_chain allocation in vectorizable_load Date: Tue, 12 Apr 2011 14:09:55 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 vectorizable_load allocates n_copies+1 dr_chains, even though only the first n_copies are needed. This patch removes the extra one and IMO makes the flow a bit more obvious. Tested on x86_64-linux-gnu and arm-linux-gnueabi. OK to install? Richard gcc/ * tree-vect-stmts.c (vectorizable_load): Allocate and free dr_chain within the per-copy loop. Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2011-04-12 11:55:07.000000000 +0100 +++ gcc/tree-vect-stmts.c 2011-04-12 11:55:08.000000000 +0100 @@ -3961,8 +3961,6 @@ vectorizable_load (gimple stmt, gimple_s } else vec_num = group_size; - - dr_chain = VEC_alloc (tree, heap, vec_num); } else { @@ -4116,6 +4114,9 @@ vectorizable_load (gimple stmt, gimple_s dataref_ptr = bump_vector_ptr (dataref_ptr, ptr_incr, gsi, stmt, NULL_TREE); + if (strided_load || slp_perm) + dr_chain = VEC_alloc (tree, heap, vec_num); + for (i = 0; i < vec_num; i++) { if (i > 0) @@ -4325,8 +4326,6 @@ vectorizable_load (gimple stmt, gimple_s return false; *vec_stmt = STMT_VINFO_VEC_STMT (stmt_info); - VEC_free (tree, heap, dr_chain); - dr_chain = VEC_alloc (tree, heap, group_size); } else { @@ -4337,11 +4336,10 @@ vectorizable_load (gimple stmt, gimple_s prev_stmt_info = vinfo_for_stmt (new_stmt); } } + if (dr_chain) + VEC_free (tree, heap, dr_chain); } - if (dr_chain) - VEC_free (tree, heap, dr_chain); - return true; }