From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 648AC3858D32; Fri, 22 Mar 2024 17:37:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 648AC3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711129054; bh=XOgPAj63koAZ1lYeCs9i+D6SAhj9YxB/1KWD8riimXk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xPRj83ElLX06jOHcC3kXy9j4K1JG/8OBE3d9h5yCC3QSQGGUY+QXuR68ja1Gh9FN3 /0i0Siik8EbM4taL2/CCMxtf6At4Cox90pi1SkrRcUX+E1m29LtBg/yDoQZPfnMORi zuZC8xeqnm0w6TeuK+2hwEzB8lMjMDa80E6poKD8= 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:37:33 +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: 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 --- Comment #8 from Jakub Jelinek --- (In reply to Richard Biener from comment #5) > but even when overflow is undefined we don't know whether we introduce > additional overflow then. Consider MAX (INT_MIN, 0) * -1 where we compute > 0 * -1 (fine) but after the transform we'd do MIN (INT_MIN * -1, 0) > which isn't valid. >=20 > And when overflow wraps consider MAX (UINT_MAX, 1) * 2 which > will compute UINT_MAX * 2 =3D=3D 0 while MAX (UINT_MAX * 2, 1 * 2) will c= ompute > 2. >=20 > Unless I'm missing something. You're right. So perhaps punt on this optimization for code =3D=3D MULT_EX= PR altogether. For the division/modulo, the problematic case is signed division by -1 (unl= ess we can prove that neither operand is signed type minimum), but c is constant here, so we could as well just punt for code =3D=3D MULT_EXPR || integer_mi= nus_onep (c)?=