From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0DD5C3858D35; Mon, 1 Jan 2024 09:39:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0DD5C3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704101981; bh=JmUV9hNPsgUl5gEfQd9LPeknpp9pIL1/c/d7ZBpOrCs=; h=From:To:Subject:Date:From; b=vH7uD6ojuaLjUofnkUuqvvFyOU2NpzYNPxwx/VDlgSC3fJwN2lvxnVqO23PuW8FvM uXj8krLGlP7F1KFc3TSJ4tvvPypN1VqO5FyhCMKQ9iR3Pb3LC1E8LmzRACLt1bY3Hk ehgxTgsXHeYXHk3J3Y2lDv4Vxh/yBxdJgEnQAqU4= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113189] New: `(-X * Y) * -X` can be optimized to `(X * Y) * X` Date: Mon, 01 Jan 2024 09:39:38 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new 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: pinskia 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: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 Bug ID: 113189 Summary: `(-X * Y) * -X` can be optimized to `(X * Y) * X` Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization, TREE Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` int f(int X, int Y) { return (-X * Y) * -X; } double fd(double X, double Y) { return (-X * Y) * -X; } int g(int X, int Y) { return ((-X) << Y) * -X; } ``` The negative should be optimized away but currently is only optimized at the RTL level.=