From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3C62A3858C83; Tue, 16 May 2023 20:06:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C62A3858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684267570; bh=Y/3ZyxlNG85L3lQ7oMwjzwkC6laGAwZD8VoisVVUUcE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=uoEWDOxC1Ds3HRShFt/Vva/BEflWzuS4vzNZ3g2jcVCSF/aaRuSPkrrNpz9fq33Jp ji7J++KFfWca5b98+7cHICAZM38NVCCNo7mANTwxlIKDJmwm0+dwchaV/1Xw8i/JhW tW8m1TPNF6SkzIQDQj1wG185u7+TC9DIhLZWR3zE= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/77579] Missed multiple add (int) for CSEd case Date: Tue, 16 May 2023 20:06:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 7.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW 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_status assigned_to 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=3D77579 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |NEW Assignee|pinskia at gcc dot gnu.org |unassigned at gcc d= ot gnu.org --- Comment #3 from Andrew Pinski --- Thinking about this some more, doing the multiply multiple times is actually slower on most cores. So this is not something you want to do normally but with a constant multip= ly you do for small power of 2 constant. E.g.: ``` void f(int x, int y, int z, int *s) { int t =3D y * 2; s[0] =3D t + x; s[1] =3D x - t; } ``` You should get: add w2, w0, w1 lsl 1 sub w0, w0, w1 lsl 1 stp w2, w0, [x3] And no seperate lsl instruction as the cost to do the lsl is free in this c= ase. Anyways I am not working on this any more.=