From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CEA263858D1E; Mon, 1 Jan 2024 09:43:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CEA263858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704102191; bh=548LDOerABjE4VNk1Th3Pbze/bTHnzbGlLpTQbnAjG8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=K3viGLTGqqnsFVRR8LmSHwTJIjWI4Tm5D8EhZMpztDeeZTWSm2+BV/JT29KyLf1yC x9RhLjson0HQzMA6sL3ii697tHe4zFJP7DpE60+aJba+NLWUqO28qrOjZLi5Qyby80 JjwG/kJTritSWQ3ElyJkKZ89xm2N5RuWrGKEm4Ik= From: "pinskia 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 09:43:10 +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: 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: 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 #1 from Andrew Pinski --- Other examples where the negative can be removed: ``` int foo(int a) { return -a * (-a * a); } int bar(int a) { return (-a * -a) * a; } int foo1(int a, int b, int c) { return -a * (-b * c); } ``` bar is handled at the gimple level but foo and foo1 are not.=