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: 90779 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 D24F7B6F1E for ; Tue, 12 Apr 2011 23:10:08 +1000 (EST) Received: (qmail 25099 invoked by alias); 12 Apr 2011 13:10:06 -0000 Received: (qmail 24997 invoked by uid 22791); 12 Apr 2011 13:10:05 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, TW_TM X-Spam-Check-By: sourceware.org Received: from mail-wy0-f175.google.com (HELO mail-wy0-f175.google.com) (74.125.82.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 12 Apr 2011 13:09:58 +0000 Received: by wye20 with SMTP id 20so6701423wye.20 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 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 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; }