From patchwork Thu Sep 29 15:57:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: argument of alloca in terms of units or not Date: Thu, 29 Sep 2011 05:57:10 -0000 From: Tom de Vries X-Patchwork-Id: 116979 Message-Id: <4E849556.5010901@mentor.com> To: Richard Guenther Cc: "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);