This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Cache reals for 1/4, 1/6 and 1/9
- From: Richard Sandiford <richard dot sandiford at arm dot com>
- To: Marc Glisse <marc dot glisse at inria dot fr>
- Cc: "gcc-patches\ at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Bernd Schmidt <bschmidt at redhat dot com>, Richard Biener <richard dot guenther at gmail dot com>
- Date: Mon, 05 Oct 2015 20:40:58 +0100
- Subject: Re: Cache reals for 1/4, 1/6 and 1/9
- Authentication-results: sourceware.org; auth=none
- References: <87twqay9vr dot fsf at e105548-lin dot cambridge dot arm dot com> <560D3C58 dot 1050805 at redhat dot com> <CAFiYyc39DGWn09ksM5tnAG00nKw57tu-Lj0nhcRb59QgJy34nw at mail dot gmail dot com> <87si5pbcev dot fsf at e105548-lin dot cambridge dot arm dot com> <56128BEF dot 2090004 at redhat dot com> <87fv1pbarj dot fsf at e105548-lin dot cambridge dot arm dot com> <561292FC dot 90409 at redhat dot com> <87bncdb68r dot fsf at e105548-lin dot cambridge dot arm dot com> <alpine dot DEB dot 2 dot 20 dot 1510051923010 dot 1721 at laptop-mg dot saclay dot inria dot fr>
Marc Glisse <marc.glisse@inria.fr> writes:
> On Mon, 5 Oct 2015, Richard Sandiford wrote:
>
>>> I do believe you still have some code growth since the inline dconst
>>> function always expands code that will initialize the constant. IMO
>>> that's not desirable.
>>
>> I don't disagree. I find dconst0 much easier to read than dconst<0> ().
>> In some ways I was posting the patch to show how bad it could be :-)
>>
>> If we're prepared to pay the cost of unconditional load-time
>> initialisation, we could have:
>>
>> template <int N>
>> struct dconst_value
>> {
>> dconst_value () { ...set up value ...; }
>> REAL_VALUE_TYPE value;
>> };
>>
>> template <int N>
>> const REAL_VALUE_TYPE &
>> dconst<T> (void)
>> {
>> static dconst_value<N> x;
>> return x.value;
>> }
>
> Why are you calling this load-time initialization? As far as I know, such
> a static object is still initialized lazily (with all the overhead this
> implies). Did you mean to make value a static member of dconst_value?
Bah, of course, sorry.