From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 34C103856602; Mon, 5 Jun 2023 07:10:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 34C103856602 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685949024; bh=Jj7fsZ9XEd0vjPNLAF2dMT+5DjpTU06u4tZE8bU4dBs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=MZeSkgz6xux6cRyPyEEPm37fag/DBIHZHv7WMR12ov4o8Rz5Rahe0Nuj9O6h8Gpq3 znlxU535W0ANVcfUYY7D509fmtJvEZ7Ao1BOhdSX1edZwqgYl/Z+6wZesNPGzQPgv6 474hLSsA1Yut/olhxDdirQEqWhD6uueVz2KDqUyk= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/43226] simplify_binary_operation_1 MINUS x const_int issue Date: Mon, 05 Jun 2023 07:10:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 4.5.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: DUPLICATE X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 7.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status resolution target_milestone see_also Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D43226 Andrew Pinski 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=3D78546 --- Comment #2 from Andrew Pinski --- The code does this now: /* Don't let a relocatable value get a negative coeff. */ if (poly_int_rtx_p (op1) && GET_MODE (op0) !=3D 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 inline POLY_POLY_RESULT (N, Ca, Ca) operator - (const poly_int_pod &a) { typedef POLY_CAST (Ca, Ca) NCa; typedef POLY_POLY_COEFF (Ca, Ca) C; poly_int r; for (unsigned int i =3D 0; i < N; i++) POLY_SET_COEFF (C, r, i, -NCa (a.coeffs[i])); return r; } typedef poly_int > > rtx_to_poly_wide_ref; operator- on generic_wide_int calls wi::neg which does: /* Return -x. */ template 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 rea= son why it was reported here but for HWI=3D=3D64 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 ***=