From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7709 invoked by alias); 1 Mar 2013 20:05:37 -0000 Received: (qmail 7699 invoked by uid 22791); 1 Mar 2013 20:05:36 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_TM X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Mar 2013 20:05:31 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r21K5UbZ016066 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 1 Mar 2013 15:05:30 -0500 Received: from zalov.cz (vpn1-7-207.ams2.redhat.com [10.36.7.207]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r21K5SFM007064 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 1 Mar 2013 15:05:30 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r21K5Sbc016401; Fri, 1 Mar 2013 21:05:28 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r21K5Rcj016400; Fri, 1 Mar 2013 21:05:27 +0100 Date: Fri, 01 Mar 2013 20:05:00 -0000 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix leaks in vectorizable_shift (PR middle-end/56461) Message-ID: <20130301200527.GC12913@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2013-03/txt/msg00041.txt.bz2 Hi! Except for the case when we set vec_oprnd1 to non-NULL, with j == 0 we always initialize vec_oprnds[01] with vect_get_vec_defs, which overwrites the vectors rather than just filling them. So we shouldn't allocate the vectors first. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2013-03-01 Jakub Jelinek PR middle-end/56461 * tree-vect-stmts.c (vectorizable_shift): Don't call create methods on vec_oprnds0 or vec_oprnds1 before loop, only call it on vec_oprnds1 right before pushing anything to it for scalar_shift_arg. --- gcc/tree-vect-stmts.c.jj 2013-02-28 22:19:57.000000000 +0100 +++ gcc/tree-vect-stmts.c 2013-03-01 11:59:03.973792955 +0100 @@ -3335,21 +3335,6 @@ vectorizable_shift (gimple stmt, gimple_ /* Handle def. */ vec_dest = vect_create_destination_var (scalar_dest, vectype); - /* Allocate VECs for vector operands. In case of SLP, vector operands are - created in the previous stages of the recursion, so no allocation is - needed, except for the case of shift with scalar shift argument. In that - case we store the scalar operand in VEC_OPRNDS1 for every vector stmt to - be created to vectorize the SLP group, i.e., SLP_NODE->VEC_STMTS_SIZE. - In case of loop-based vectorization we allocate VECs of size 1. We - allocate VEC_OPRNDS1 only in case of binary operation. */ - if (!slp_node) - { - vec_oprnds0.create (1); - vec_oprnds1.create (1); - } - else if (scalar_shift_arg) - vec_oprnds1.create (slp_node->vec_stmts_size); - prev_stmt_info = NULL; for (j = 0; j < ncopies; j++) { @@ -3369,6 +3354,7 @@ vectorizable_shift (gimple stmt, gimple_ dump_printf_loc (MSG_NOTE, vect_location, "operand 1 using scalar mode."); vec_oprnd1 = op1; + vec_oprnds1.create (slp_node ? slp_node->vec_stmts_size : 1); vec_oprnds1.quick_push (vec_oprnd1); if (slp_node) { Jakub