diff options
author | Jakub Jelinek <jakub@redhat.com> | 2023-05-06 10:57:41 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2023-05-06 10:58:50 +0200 |
commit | b7fe38c14e5f1bc32950c7b2ffc8537c7c381af4 (patch) | |
tree | 3ebf0ec95834d13a1ac5977e3e549c9260f393b8 /gcc/real.h | |
parent | 143e6695b20d3522e11f6e74b587993f9f619ccb (diff) | |
download | gcc-b7fe38c14e5f1bc32950c7b2ffc8537c7c381af4.zip gcc-b7fe38c14e5f1bc32950c7b2ffc8537c7c381af4.tar.gz gcc-b7fe38c14e5f1bc32950c7b2ffc8537c7c381af4.tar.bz2 |
gimple-range-op: Improve handling of sin/cos ranges
Similarly to the earlier sqrt patch, this patch attempts to improve
sin/cos ranges. As the functions are periodic, for the reverse range
there is not much we can do (but I've discovered I forgot to take
into account the boundary ulps for the discovery of impossible result
ranges). For fold_range, we can do something only if the range is
narrow enough (narrower than 2*pi). The patch computes the value of
the functions (taking ulps into account) and also computes the derivative
to find out if the function is growing or declining on the boundaries and
from that it figures out if the result range should be
[min (fn (lb), fn (ub)), max (fn (lb), fn (ub))] or if it needs to be
extended to 1 (actually using +Inf) and/or -1 (actually using -Inf) because
there must be a local minimum and/or maximum in the range.
2023-05-06 Jakub Jelinek <jakub@redhat.com>
* real.h (dconst_pi): Define.
(dconst_e_ptr): Formatting fix.
(dconst_pi_ptr): Declare.
* real.cc (dconst_pi_ptr): New function.
* gimple-range-op.cc (cfn_sincos::fold_range): Intersect the generic
boundaries range with range computed from sin/cos of the particular
bounds if the argument range is shorter than 2*pi.
(cfn_sincos::op1_range): Take bulps into account when determining
which result ranges are always invalid or behave like known NAN.
* gcc.dg/tree-ssa/range-sincos-2.c: New test.
Diffstat (limited to 'gcc/real.h')
-rw-r--r-- | gcc/real.h | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -480,9 +480,13 @@ extern REAL_VALUE_TYPE dconstninf; #define dconst_sixth() (*dconst_sixth_ptr ()) #define dconst_ninth() (*dconst_ninth_ptr ()) #define dconst_sqrt2() (*dconst_sqrt2_ptr ()) +#define dconst_pi() (*dconst_pi_ptr ()) /* Function to return the real value special constant 'e'. */ -extern const REAL_VALUE_TYPE * dconst_e_ptr (void); +extern const REAL_VALUE_TYPE *dconst_e_ptr (void); + +/* Function to return the real value special constant 'pi'. */ +extern const REAL_VALUE_TYPE *dconst_pi_ptr (void); /* Returns a cached REAL_VALUE_TYPE corresponding to 1/n, for various n. */ extern const REAL_VALUE_TYPE *dconst_third_ptr (void); |