From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5281E3857C74; Tue, 5 Jan 2021 08:31:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5281E3857C74 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/98350] Reassociation breaks FMA chains Date: Tue, 05 Jan 2021 08:31:20 +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: 11.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth 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: version everconfirmed cf_reconfirmed_on bug_status 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jan 2021 08:31:21 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98350 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Version|unknown |11.0 Ever confirmed|0 |1 Last reconfirmed| |2021-01-05 Status|UNCONFIRMED |NEW --- Comment #1 from Richard Biener --- There is no built-in way, and yes, reassoc-width is known to have this effe= ct. What could be done is move/duplicate FMA discovery from pass_optimize_widening_mul to reassoc(*). The simplistic idea would be to perform a separate FMA detection on the OPS array. The question is how to handle imperfect chains where reassoc would order after rank, like a[i] +=3D b[i]* c[i] + d[i] + f[i] * g[i] + h[i] + k[i] * l[i] + m[i] + p[i= ]; and also how to not "break" the special heuristics the current FMA formation pass has. Alternatively altering rewrite_expr_tree_parallel only to avoid splitting FMA chains in unwanted ways would be possible. (*) note since reassoc doesn't handle signed integer arithmetic it cannot fully replace late FMA detect=