From patchwork Thu Sep 29 15:57:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 116979 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 4CD081007D4 for ; Fri, 30 Sep 2011 01:55:41 +1000 (EST) Received: (qmail 29642 invoked by alias); 29 Sep 2011 15:55:38 -0000 Received: (qmail 29632 invoked by uid 22791); 29 Sep 2011 15:55:36 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,TW_TM X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 29 Sep 2011 15:55:21 +0000 Received: from nat-dem.mentorg.com ([195.212.93.2] helo=eu2-mail.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1R9IxD-0000vR-W1 from Tom_deVries@mentor.com ; Thu, 29 Sep 2011 08:55:20 -0700 Received: from [127.0.0.1] ([172.16.63.104]) by eu2-mail.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 29 Sep 2011 17:55:18 +0200 Message-ID: <4E849556.5010901@mentor.com> Date: Thu, 29 Sep 2011 17:57:10 +0200 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Lightning/1.0b2 Thunderbird/3.1.13 MIME-Version: 1.0 To: Richard Guenther CC: "gcc-patches@gcc.gnu.org" Subject: argument of alloca in terms of units or not 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, in gimplify_vla_decl, the alloca argument seems to be the size of the vla in units: ... t = build_call_expr (t, 1, DECL_SIZE_UNIT (decl)); ... I wonder why we are going through this 8 vs. BITS_PER_UNIT conversion here: ... elem_type = build_nonstandard_integer_type (BITS_PER_UNIT, 1); n_elem = size * 8 / BITS_PER_UNIT; align = MIN (size * 8, BIGGEST_ALIGNMENT); ... The element size is BITS_PER_UNIT, so 1 unit, and size is in units. Shouldn't this be: ... ... Thanks, - Tom Index: tree-ssa-ccp.c =================================================================== --- tree-ssa-ccp.c (revision 179210) +++ tree-ssa-ccp.c (working copy) @@ -1722,8 +1722,8 @@ fold_builtin_alloca_for_var (gimple stmt /* Declare array. */ elem_type = build_nonstandard_integer_type (BITS_PER_UNIT, 1); - n_elem = size * 8 / BITS_PER_UNIT; - align = MIN (size * 8, BIGGEST_ALIGNMENT); + n_elem = size; + align = MIN (size * BITS_PER_UNIT, BIGGEST_ALIGNMENT); if (align < BITS_PER_UNIT) align = BITS_PER_UNIT; array_type = build_array_type_nelts (elem_type, n_elem);