This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cache reals for 1/4, 1/6 and 1/9


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]