From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5F2EE3858C2F; Mon, 1 Jan 2024 13:31:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F2EE3858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704115913; bh=mVx8aYTR4dQWvbx9xglqebVixo9lInGExOHpuoHTM3s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dOQfGePnOgWQMvEqUKyjmo+oVNqvKT7LVOObnUrDPbqDuwL7ILVyJpsHYLEn3v25Y BIg++AotJkbXT6ohJVJCKd6W7DJD5WjAZFcY8QIVI6rwrSgSmaOxaJPSLAOOttFH7z DxKaKiRRSQmnHRiygteu01SYQmhlisF8694X5jgo= From: "jsm28 at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113189] `(-X * Y) * -X` can be optimized to `(X * Y) * X` Date: Mon, 01 Jan 2024 13:31: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: 14.0 X-Bugzilla-Keywords: missed-optimization, TREE X-Bugzilla-Severity: enhancement X-Bugzilla-Who: jsm28 at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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=3D113189 --- Comment #2 from Joseph S. Myers --- If Y is INT_MIN and X is -1, removing the negations introduces undefined behavior in the first example (-(-1) * INT_MIN * -(-1) is valid, -1 * INT_M= IN * -1 has undefined behavior). For floating types, removing the negations isn't valid if flag_rounding_mat= h.=