public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* ggc_alloc_rtvec_sized allocates spaces more than necessary?
@ 2011-08-15 12:17 王亮
  2011-08-15 12:20 ` Richard Guenther
  2011-08-15 17:22 ` Andreas Schwab
  0 siblings, 2 replies; 7+ messages in thread
From: 王亮 @ 2011-08-15 12:17 UTC (permalink / raw)
  To: gcc

Hi,

Current implementation of ggc_alloc_rtvec_sized is

#define ggc_alloc_rtvec_sized(NELT)                                     \
    (ggc_alloc_zone_vec_rtvec_def (sizeof (rtx),                        \
                                   sizeof (struct rtvec_def) + ((NELT) - 1), \
                                   &rtl_zone))

The size it allocates is

  (sizeof (struct rtvec_def) + ((NELT) - 1)) * sizeof (rtx)
     // (1)

Originally, the allocated size is

  sizeof (struct rtvec_def) + ((NELT) - 1) * sizeof (rtx)
    // (2)

So current implementation allocates more spaces than before.

I replace the second parameter of ggc_alloc_zone_vec_rtvec_def with

  (sizeof (struct rtvec_def) + sizeof (rtx) - 1) / sizeof (rtx) +
((NELT) - 1)   // (3)

It bootstraps on x86 successfully.  So I guess the extra spaces are
not used.  Did I miss something?

Thanks,
Liang.

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

* Re: ggc_alloc_rtvec_sized allocates spaces more than necessary?
  2011-08-15 12:17 ggc_alloc_rtvec_sized allocates spaces more than necessary? 王亮
@ 2011-08-15 12:20 ` Richard Guenther
  2011-08-16  5:52   ` Laurynas Biveinis
  2011-08-15 17:22 ` Andreas Schwab
  1 sibling, 1 reply; 7+ messages in thread
From: Richard Guenther @ 2011-08-15 12:20 UTC (permalink / raw)
  To: 王亮; +Cc: gcc, Laurynas Biveinis

On Mon, Aug 15, 2011 at 2:16 PM, 王亮 <netcasper@gmail.com> wrote:
> Hi,
>
> Current implementation of ggc_alloc_rtvec_sized is
>
> #define ggc_alloc_rtvec_sized(NELT)                                     \
>    (ggc_alloc_zone_vec_rtvec_def (sizeof (rtx),                        \
>                                   sizeof (struct rtvec_def) + ((NELT) - 1), \
>                                   &rtl_zone))
>
> The size it allocates is
>
>  (sizeof (struct rtvec_def) + ((NELT) - 1)) * sizeof (rtx)

This looks indeed bogus.

>     // (1)
>
> Originally, the allocated size is
>
>  sizeof (struct rtvec_def) + ((NELT) - 1) * sizeof (rtx)
>    // (2)

This one is correct.

Laurynas?

> So current implementation allocates more spaces than before.
>
> I replace the second parameter of ggc_alloc_zone_vec_rtvec_def with
>
>  (sizeof (struct rtvec_def) + sizeof (rtx) - 1) / sizeof (rtx) +
> ((NELT) - 1)   // (3)
>
> It bootstraps on x86 successfully.  So I guess the extra spaces are
> not used.  Did I miss something?
>
> Thanks,
> Liang.
>

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

* Re: ggc_alloc_rtvec_sized allocates spaces more than necessary?
  2011-08-15 12:17 ggc_alloc_rtvec_sized allocates spaces more than necessary? 王亮
  2011-08-15 12:20 ` Richard Guenther
@ 2011-08-15 17:22 ` Andreas Schwab
  2011-08-16  5:52   ` Laurynas Biveinis
  1 sibling, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2011-08-15 17:22 UTC (permalink / raw)
  To: 王亮; +Cc: gcc

王亮 <netcasper@gmail.com> writes:

> Hi,
>
> Current implementation of ggc_alloc_rtvec_sized is
>
> #define ggc_alloc_rtvec_sized(NELT)                                     \
>     (ggc_alloc_zone_vec_rtvec_def (sizeof (rtx),                        \
>                                    sizeof (struct rtvec_def) + ((NELT) - 1), \
>                                    &rtl_zone))
>
> The size it allocates is
>
>   (sizeof (struct rtvec_def) + ((NELT) - 1)) * sizeof (rtx)
>      // (1)
>
> Originally, the allocated size is
>
>   sizeof (struct rtvec_def) + ((NELT) - 1) * sizeof (rtx)
>     // (2)
>
> So current implementation allocates more spaces than before.
>
> I replace the second parameter of ggc_alloc_zone_vec_rtvec_def with
>
>   (sizeof (struct rtvec_def) + sizeof (rtx) - 1) / sizeof (rtx) +
> ((NELT) - 1)   // (3)

I think it was meant to be this:

#define ggc_alloc_rtvec_sized(NELT)                                     \
  ggc_alloc_zone_rtvec_def (sizeof (struct rtvec_def)			\
			    + ((NELT) - 1) * sizeof (rtx),		\
			    &rtl_zone)

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: ggc_alloc_rtvec_sized allocates spaces more than necessary?
  2011-08-15 12:20 ` Richard Guenther
@ 2011-08-16  5:52   ` Laurynas Biveinis
  2011-08-16  9:37     ` Liang Wang
  0 siblings, 1 reply; 7+ messages in thread
From: Laurynas Biveinis @ 2011-08-16  5:52 UTC (permalink / raw)
  To: Richard Guenther; +Cc: 王亮, gcc

> On Mon, Aug 15, 2011 at 2:16 PM, 王亮 <netcasper@gmail.com> wrote:
>> The size it allocates is
>>
>>  (sizeof (struct rtvec_def) + ((NELT) - 1)) * sizeof (rtx)

>> Originally, the allocated size is
>>
>>  sizeof (struct rtvec_def) + ((NELT) - 1) * sizeof (rtx)

Yes, this is correct, good catch.

>>  (sizeof (struct rtvec_def) + sizeof (rtx) - 1) / sizeof (rtx) +
>> ((NELT) - 1)   // (3)

Due to the way those macros expand, right now replacing the first arg
with "1" and the second one with straightforward "sizeof (struct
rtvec_def) + ((NELT) - 1) * sizeof (rtx)" will work and will be easier
to read than division. Liang, would you submit such patch?

Thanks again,
-- 
Laurynas

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

* Re: ggc_alloc_rtvec_sized allocates spaces more than necessary?
  2011-08-15 17:22 ` Andreas Schwab
@ 2011-08-16  5:52   ` Laurynas Biveinis
  2011-08-16  7:24     ` Andreas Schwab
  0 siblings, 1 reply; 7+ messages in thread
From: Laurynas Biveinis @ 2011-08-16  5:52 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 王亮, gcc

2011/8/15 Andreas Schwab <schwab@linux-m68k.org>:
> I think it was meant to be this:
>
> #define ggc_alloc_rtvec_sized(NELT)                                     \
>  ggc_alloc_zone_rtvec_def (sizeof (struct rtvec_def)                   \
>                            + ((NELT) - 1) * sizeof (rtx),              \
>                            &rtl_zone)

Note that ggc_alloc_zone_rtvec_def takes three args, not two.

-- 
Laurynas

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

* Re: ggc_alloc_rtvec_sized allocates spaces more than necessary?
  2011-08-16  5:52   ` Laurynas Biveinis
@ 2011-08-16  7:24     ` Andreas Schwab
  0 siblings, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2011-08-16  7:24 UTC (permalink / raw)
  To: Laurynas Biveinis; +Cc: 王亮, gcc

Laurynas Biveinis <laurynas.biveinis@gmail.com> writes:

> 2011/8/15 Andreas Schwab <schwab@linux-m68k.org>:
>> I think it was meant to be this:
>>
>> #define ggc_alloc_rtvec_sized(NELT)                                     \
>>  ggc_alloc_zone_rtvec_def (sizeof (struct rtvec_def)                   \
>>                            + ((NELT) - 1) * sizeof (rtx),              \
>>                            &rtl_zone)
>
> Note that ggc_alloc_zone_rtvec_def takes three args, not two.

No, it does not of course.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: ggc_alloc_rtvec_sized allocates spaces more than necessary?
  2011-08-16  5:52   ` Laurynas Biveinis
@ 2011-08-16  9:37     ` Liang Wang
  0 siblings, 0 replies; 7+ messages in thread
From: Liang Wang @ 2011-08-16  9:37 UTC (permalink / raw)
  To: Laurynas Biveinis; +Cc: Richard Guenther, gcc

On Tue, Aug 16, 2011 at 1:51 PM, Laurynas Biveinis
<laurynas.biveinis@gmail.com> wrote:
>> On Mon, Aug 15, 2011 at 2:16 PM, 王亮 <netcasper@gmail.com> wrote:
>>> The size it allocates is
>>>
>>>  (sizeof (struct rtvec_def) + ((NELT) - 1)) * sizeof (rtx)
>
>>> Originally, the allocated size is
>>>
>>>  sizeof (struct rtvec_def) + ((NELT) - 1) * sizeof (rtx)
>
> Yes, this is correct, good catch.
>
>>>  (sizeof (struct rtvec_def) + sizeof (rtx) - 1) / sizeof (rtx) +
>>> ((NELT) - 1)   // (3)
>
> Due to the way those macros expand, right now replacing the first arg
> with "1" and the second one with straightforward "sizeof (struct
> rtvec_def) + ((NELT) - 1) * sizeof (rtx)" will work and will be easier
> to read than division. Liang, would you submit such patch?

Yes, I have sent patch to gcc-patches.

>
> Thanks again,
> --
> Laurynas
>

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

end of thread, other threads:[~2011-08-16  9:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-15 12:17 ggc_alloc_rtvec_sized allocates spaces more than necessary? 王亮
2011-08-15 12:20 ` Richard Guenther
2011-08-16  5:52   ` Laurynas Biveinis
2011-08-16  9:37     ` Liang Wang
2011-08-15 17:22 ` Andreas Schwab
2011-08-16  5:52   ` Laurynas Biveinis
2011-08-16  7:24     ` Andreas Schwab

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