]> gcc.gnu.org Git - gcc.git/commit
range-op: Cleanup floating point multiplication and division fold_range [PR107569]
authorJakub Jelinek <jakub@redhat.com>
Sat, 12 Nov 2022 08:36:59 +0000 (09:36 +0100)
committerJakub Jelinek <jakub@redhat.com>
Sat, 12 Nov 2022 08:40:48 +0000 (09:40 +0100)
commit5747470efa8ff0ac82bb5f53d737b29a44f18118
treededa4419d16ed0b672b023d354e760e21556501c
parent2d5c4a16dd833aa083f13dd3e78e3ef38afe6ebb
range-op: Cleanup floating point multiplication and division fold_range [PR107569]

Admittedly there are many similar spots with the foperator_div case
(but also with significant differences), so perhaps if foperator_{mult,div}
inherit from some derived class from range_operator_float and that class
would define various smaller helper static? methods, like this
discussed in the PR - contains_zero_p, singleton_nan_p, zero_p,
that
+           bool must_have_signbit_zero = false;
+           bool must_have_signbit_nonzero = false;
+           if (real_isneg (&lh_lb) == real_isneg (&lh_ub)
+               && real_isneg (&rh_lb) == real_isneg (&rh_ub))
+             {
+               if (real_isneg (&lh_lb) == real_isneg (&rh_ub))
+                 must_have_signbit_zero = true;
+               else
+                 must_have_signbit_nonzero = true;
+             }
returned as -1/0/1 int, and those set result (based on the above value) to
[+INF, +INF], [-INF, -INF] or [-INF, +INF]
or
[+0, +0], [-0, -0] or [-0, +0]
or
[+0, +INF], [-INF, -0] or [-INF, +INF]
and the
+    for (int i = 1; i < 4; ++i)
+      {
+       if (real_less (&cp[i], &cp[0])
+           || (real_iszero (&cp[0]) && real_isnegzero (&cp[i])))
+         std::swap (cp[i], cp[0]);
+       if (real_less (&cp[4], &cp[i + 4])
+           || (real_isnegzero (&cp[4]) && real_iszero (&cp[i + 4])))
+         std::swap (cp[i + 4], cp[4]);
+      }
block, it could be smaller and more readable.

2022-11-12  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/107569
* range-op-float.cc (zero_p, contains_p, singleton_inf_p,
signbit_known_p, zero_range, inf_range, zero_to_inf_range): New
functions.
(foperator_mult_div_base): New class.
(foperator_mult, foperator_div): Derive from that and use
protected static method from it as well as above new functions
to simplify the code.
gcc/range-op-float.cc
This page took 0.062454 seconds and 5 git commands to generate.