Re: [COMMITTERS] pgsql: Add trigonometric functions that work in degrees.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [COMMITTERS] pgsql: Add trigonometric functions that work in degrees.
Date: 2016-04-25 02:56:32
Message-ID: 7284.1461552992@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> On 04/21/2016 08:18 PM, Tom Lane wrote:
>> Could you send along the assembler code generated by the compiler (-S
>> output) for float.c? Maybe that would shed some light. Probably the
>> -O0 version would be easier to read.

> Attached is a smaller test program that prints 29.9999999999999964 (same
> as failing test result) as well as its assembler code.

This doesn't prove much. It's clear from the assembly code that the
compiler is evaluating "asin(0.5)" at compile time (and, presumably,
getting a different answer than would be produced at runtime). But
that's entirely unsurprising given this source text: you've got a
naked application of asin() to a constant. What we need to know,
and what this doesn't quite prove, is whether the compiler is managing
to see through the tricks that float.c uses to prevent compile-time
calculation of that value.

The fact that this produces the same number as we see in the regression
test does point to the idea that that's what's happening. But it's not
conclusive. Part of the reason I'm not sold is that even if the compiler
can see through those tricks when optimizing, it hardly seems like it
should do so at -O0.

If that is the answer, then the next question is how we can put more
roadblocks in the way of compile-time evaluation of asin(0.5). Dean
suggested that creative use of "volatile" might do it, and I agree
that that sounds like a promising thing to pursue.

regards, tom lane

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Magnus Hagander 2016-04-25 13:24:44 Re: pgsql: Add putenv support for msvcrt from Visual Studio 2013
Previous Message Peter Eisentraut 2016-04-25 02:42:29 Re: [COMMITTERS] pgsql: Add trigonometric functions that work in degrees.

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-04-25 03:01:42 Re: Rename max_parallel_degree?
Previous Message Robert Haas 2016-04-25 02:44:31 Re: Rename max_parallel_degree?