From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 236743858412; Mon, 25 Mar 2024 11:01:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 236743858412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711364476; bh=FkACMQqgOMxgcIHsTsW+klcN0IZevUP/rED72Fl8PfA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=iYMQIXGI2Zqlwby3j4WBHsqnsUKmD0ATICEA12S0Yw9Ky2Y4ltE12QiBGjvlGROxY z5bn2A10+vciehPJarplo2FbjZJhn//h5rSdDRZzJa59ej9aqF3vNQoHDpPmUeDsp9 7jlNw72LI8VtmOdaGGsOMGdtmppQsoxPKgNoByaI= 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: Mon, 25 Mar 2024 11:01:14 +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 #14 from Jakub Jelinek --- (In reply to Jakub Jelinek from comment #12) > The following testcase at least reproduces the unsigned multiplication > issue, but doesn't reproduce the signed multiplication nor division by -1. > int > main () > { > unsigned a =3D (1U + __INT_MAX__) / 2U; > unsigned b =3D 1U; > unsigned c =3D (a * 2U > b * 2U ? a * 2U : b * 2U) * 2U; > if (c !=3D 0U) > __builtin_abort (); > int d =3D (-__INT_MAX__ - 1) / 2; > int e =3D 10; > int f =3D (d * 2 > e * 2 ? d * 2 : e * 2) * 6; > if (f !=3D 120) > __builtin_abort (); > int g =3D (-__INT_MAX__ - 1) / 2; > int h =3D 0; > int i =3D (g * 2 > h * 2 ? g * 2 : h * 2) / -1; > if (i !=3D 0) > __builtin_abort (); > } Ah, the reason it doesn't fail for the f and i cases is that for the signed type cases, we actually don't create a MIN_EXPR or MAX_EXPR but COND_EXPR w= hich just compares the vars and performs multiplication only in the COND_EXPR second/third arguments. So it is kind of hard trying to make it trigger for the problematic cases w= here the recursive calls would extract something. Will see in full bootstrap/regtest with logging how often does the patch trigger.=