https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112468

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Tamar Christina from comment #3)
> Hmm I rather think PHI ops should handle that null like other passes do. The
> folding is supposed to already test and only happen if it succeeds.


It handles the null just fine.
If you look at the output I posted,
we start with "A_2(D) <= 0.0 ? A_2(D) : _3" where _3 is -A_2(D)

The matches this pattern:
 /* A <=/< 0 ? A : -A    same as -abs (A) */
 (for cmp (le lt)
  (simplify
   (cnd (cmp @0 zerop) @1 (negate @1))
    (if (!HONOR_SIGNED_ZEROS (TREE_TYPE(@0))
         && !TYPE_UNSIGNED (TREE_TYPE(@0))
         && bitwise_equal_p (@0, @1))
     (if ((ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0))
           && !TYPE_OVERFLOW_WRAPS (TREE_TYPE (@0)))
          || TYPE_UNSIGNED (type))
      (with {
        tree utype = unsigned_type_for (TREE_TYPE(@0));
       }
       (convert (negate (absu:utype @0))))
       (negate (abs @0)))))

But then match tries to simplify (negate (abs @0)) .
phiopt was not involved in that simplification of the -abs(a) to ifn_copysign
but only match and simplify.

Reply via email to