From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BEFEE3858419; Fri, 22 Mar 2024 17:29:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BEFEE3858419 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711128550; bh=4JcOWI54MtVtUem6TNxJ14cgHtkauMNyuT+gqmStDAQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qjHSyG9Hbm+fdN94A8TiIH49lNEOR9uhT5klivs8uJT5qqbeop6I4IWTgyyGDAQTP D9S5WJrdfPjB9xbJ0Sv9fOgf1VzkydZ5lReN6/mIrfQjIGTbxVjkIrac1IvasP126U qvwgWlEACpOx3Ea6KBc7JoddIRfNDrtDgU0qJNqY= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/111151] [12/13/14 Regression] Wrong code at -O0 on x86_64-pc-linux-gnu Date: Fri, 22 Mar 2024 17:29:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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=3D111151 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #7 from Jakub Jelinek --- (In reply to Richard Biener from comment #3) > @@ -6970,8 +6972,11 @@ extract_muldiv_1 (tree t, tree c, enum tree_code > code, tree wide_type, >=20=20 > /* MIN (a, b) / 5 -> MIN (a / 5, b / 5) */ > sub_strict_overflow_p =3D false; > - if ((t1 =3D extract_muldiv (op0, c, code, wide_type, > - &sub_strict_overflow_p)) !=3D 0 > + if ((wide_type > + ? TYPE_OVERFLOW_UNDEFINED (wide_type) > + : TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (op0)))=20 > + && (t1 =3D extract_muldiv (op0, c, code, wide_type, > + &sub_strict_overflow_p)) !=3D 0 > && (t2 =3D extract_muldiv (op1, c, code, wide_type, > &sub_strict_overflow_p)) !=3D 0) > { Isn't it fine as is for unsigned divisions and modulos? I'd think the only problem is TYPE_OVERFLOW_WRAPS code =3D=3D MULT_EXPR or !TYPE_UNSIGNED && TYPE_OVERFLOW_WRAPS division/modulo (say -fwrapv MIN (a, = b) / -1 -> MAX (a / -1, b / -1) transformation wouldn't be correct for a INT_MIN b = 0, because the first one is INT_MIN / -1 aka. INT_MIN, while the latter is 0 or perhaps TYPE_OVERFLOW_SANITIZED should be punted on as well.=