Re: Use static inline functions for Float <-> Datum conversions - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Use static inline functions for Float <-> Datum conversions
Date
Msg-id 752262dc-0a51-22bd-9cfa-88532d2d8dc2@iki.fi
Whole thread Raw
In response to Re: Use static inline functions for Float <-> Datum conversions  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Use static inline functions for Float <-> Datum conversions  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 08/31/2016 02:38 PM, Tom Lane wrote:
> Heikki Linnakangas <hlinnaka@iki.fi> writes:
>> Now that we are OK with static inline functions, we can save some cycles
>> from floating-point functions, by turning Float4GetDatum,
>> Float8GetDatum, and DatumGetFloat8 into static inlines.
>
> Looks good to me.

Ok, will push.

> I wonder whether there is a compiler-dependent way of avoiding the union
> trick ... or maybe gcc is already smart enough that it doesn't matter?

It seems to compile into a single instruction, so it can't get any 
better from a performance point of view.

float8pl:
.LFB79:.loc 1 871 0.cfi_startproc
.LVL297:
.LBB959:
.LBB960:.loc 2 733 0movsd    40(%rdi), %xmm2
.LBE960:
.LBE959:
.LBB961:
.LBB962:movsd    32(%rdi), %xmm1
...

A union is probably what language pedantics would prefer anyway, and 
anything else would be more of a trick.

- Heikki




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Use static inline functions for Float <-> Datum conversions
Next
From: Daniel Gustafsson
Date:
Subject: Leftover member in openssl part of Port struct