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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
new_stmt = build_call_internal (ifn, res_op);

static gcall *
build_call_internal (internal_fn fn, gimple_match_op *res_op)
{
  if (direct_internal_fn_p (fn))
    {
      tree_pair types = direct_internal_fn_types (fn, res_op->type,
                                                  res_op->ops);
      if (!direct_internal_fn_supported_p (fn, types, OPTIMIZE_FOR_BOTH))
        return NULL; // here.
    }


Causes copysign to return NULL here ....

I suspect the pattern should be changed to:
/* Transform fneg (fabs (X)) -> copysign (X, -1).  */
(simplify
 (negate (abs @0))
 (if (direct_internal_fn_supported_p (IFN_COPYSIGN, type, OPTIMIZE_FOR_BOTH))
  (IFN_COPYSIGN @0 { build_minus_one_cst (type); })))


Notice the check against direct_internal_fn_supported_p here.

This is similar to the (trunc)copysign((extend)..) pattern.

/* Simplify (trunc)copysign ((extend)x, (extend)y) to copysignf (x, y),
   x,y is float value, similar for _Float16/double.  */
(for copysigns (COPYSIGN_ALL)
 (simplify
  (convert (copysigns (convert@2 @0) (convert @1)))

Reply via email to