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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE
   Target Milestone|---                         |7.0
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=78546

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The code does this now:
      /* Don't let a relocatable value get a negative coeff.  */
      if (poly_int_rtx_p (op1) && GET_MODE (op0) != VOIDmode)
        return simplify_gen_binary (PLUS, mode,
                                    op0,
                                    neg_poly_int_rtx (mode, op1));


Which does:
/* Negate I, which satisfies poly_int_rtx_p.  MODE is the mode of I.  */

static rtx
neg_poly_int_rtx (machine_mode mode, const_rtx i)
{
  return immed_wide_int_const (-wi::to_poly_wide (i, mode), mode);
}


Poly_int's operator- does:
template<unsigned int N, typename Ca>
inline POLY_POLY_RESULT (N, Ca, Ca)
operator - (const poly_int_pod<N, Ca> &a)
{
  typedef POLY_CAST (Ca, Ca) NCa;
  typedef POLY_POLY_COEFF (Ca, Ca) C;
  poly_int<N, C> r;
  for (unsigned int i = 0; i < N; i++)
    POLY_SET_COEFF (C, r, i, -NCa (a.coeffs[i]));
  return r;
}

  typedef poly_int<NUM_POLY_INT_COEFFS,
                   generic_wide_int <wide_int_ref_storage <false, false> > >
    rtx_to_poly_wide_ref;

operator- on generic_wide_int calls wi::neg which does:
/* Return -x.  */
template <typename T>
inline WI_UNARY_RESULT (T)
wi::neg (const T &x)
{
  return sub (0, x);
}


wi::sub only uses `unsigned HOST_WIDE_INT`


r10-3327-g681fc0fa40cc moved it over to poly_int.



But r7-4950-gd057004733e8 (PR 78546) fixed this bug really for the same reason
why it was reported here but for HWI==64 and int128_t.

I am going to mark this as a dup of bug 78546 because the bug is the same.

*** This bug has been marked as a duplicate of bug 78546 ***

Reply via email to