public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* argument of alloca in terms of units or not
@ 2011-09-29 18:09 Tom de Vries
  2011-09-30  8:56 ` Richard Guenther
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2011-09-29 18:09 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc-patches

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:
...
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);
...

Thanks,
- Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: argument of alloca in terms of units or not
  2011-09-29 18:09 argument of alloca in terms of units or not Tom de Vries
@ 2011-09-30  8:56 ` Richard Guenther
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Guenther @ 2011-09-30  8:56 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gcc-patches

On Thu, Sep 29, 2011 at 5:57 PM, Tom de Vries <Tom_deVries@mentor.com> wrote:
> 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.

No, the size is in bytes and the gimplify code lacks the conversion.

Richard.

>
> Shouldn't this be:
> ...
> 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);
> ...
>
> Thanks,
> - Tom
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-09-30  8:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-29 18:09 argument of alloca in terms of units or not Tom de Vries
2011-09-30  8:56 ` Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).