From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C6A0E3858D20; Sun, 19 May 2024 22:47:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C6A0E3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1716158872; bh=ejVHq2x1d16Z/R5h2jZUyYP/DtJqqdkDbXEQpTCMDW0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mwVZ1BYBC+sCpU+OFcX5z3mYLsOQYEYKQa3v596W6tpuazGSMFaoGjY6rE5TmzuD5 bTH2Uw2+GVSkSSOjZXNU4/CWZBcVyIkAM98wQ/nY/lVT/Gf0uqF14r0EFN0bXvm4jl u1uI+zATxI4gI1Iyb9rerKwJl7t3txihJxA1Xxmk= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/115154] [13 Regression] wrong code at optimization levels -O2, -O3, -Os since r13-7434-g682bbd364708fe Date: Sun, 19 May 2024 22:47:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: pinskia at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.3 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=3D115154 --- Comment #9 from Andrew Pinski --- Matching expression match.pd:2310, gimple-match-3.cc:90 Matching expression match.pd:2310, gimple-match-3.cc:90 Applying pattern match.pd:4890, gimple-match-2.cc:4798 Matching expression match.pd:160, gimple-match-10.cc:33 Matching expression match.pd:2243, gimple-match-5.cc:20 Matching expression match.pd:160, gimple-match-10.cc:33 Applying pattern match.pd:5024, gimple-match-7.cc:13241 Applying pattern match.pd:2404, gimple-match-2.cc:4387 gimple_simplified to _32 =3D () _2; _29 =3D -_32; The problem match pattern (r13-1162-g9991d84d2a8435) is: ``` /* Narrow integer multiplication by a zero_one_valued_p operand. Multiplication by [0,1] is guaranteed not to overflow. */ (simplify (convert (mult@0 zero_one_valued_p@1 INTEGER_CST@2)) (if (INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (TREE_TYPE (@0)) && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (@0))) (mult (convert @1) (convert @2)))) ``` _36 =3D _27 * 5; _29 =3D () _36; We go from `()(_27 *5)` to `(()_27) * -= 1` which does overflow. The only case where is an overflow is `signed:1` so we should reject that I think.=