From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3254A3858D32; Fri, 22 Mar 2024 17:41:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3254A3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711129286; bh=+5Q3x5S0PVWwQ2YScE/npRlMq+gan+kpC6xqb1d1JmM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=wR4W9zf32uUlg8FJeYAb08eX2vLJ6YXdIxbrJyJ4IwgxiB3OrRjPSUABsyEWP9BbY R6zEWTAQsA3KsQ7cs7uBuYn1yhwxImYmSFDFAU2GJNYHz5j4G+bVZ0ig9TKU08eOXp UzS149YAr1LRQes+3Q/bVKoCcNxGL+4qnNCQLRzU= 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:41:25 +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 #9 from Jakub Jelinek --- (In reply to Jakub Jelinek from comment #8) > (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 comp= ute > > 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= compute > > 2. > >=20 > > Unless I'm missing something. >=20 > You're right. So perhaps punt on this optimization for code =3D=3D MULT_= EXPR > altogether. Although, even for MULT_EXPR when TYPE_OVERFLOW_UNDEFINED, if the only problematic cases are when one of the multiplication operand is -1 and the other is sig= ned minimum, because we know one of those operands (c), we could just punt if integer_minus_onep (c) or if c is TYPE_MIN_VALUE.=