From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 253973858C52; Tue, 21 Mar 2023 19:25:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 253973858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679426750; bh=czT7trBdQt2vztll2azeLqRB/5h2B24fICTZka8XEFA=; h=From:To:Subject:Date:From; b=LmOqM8UMl2QmB0uGTWOHiaQOg1HrXTEoi8PKRtEw22sK5rNGkHDe94HUi7EwZ2N4F qzWcvgFbEq/l6uPAAgF6CkxhgScWto76n3I3UpPiYeeSjyyEz1aOhQ6v3+MDlH/EdF 62T42HrI4JFBz6x9icNptjPnoed59NeFjJeu1OTc= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109240] New: Missed fneg/fsub optimization Date: Tue, 21 Mar 2023 19:25:49 +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: 13.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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 cc dependson target_milestone cf_gcchost cf_gcctarget 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=3D109240 Bug ID: 109240 Summary: Missed fneg/fsub optimization Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org CC: avieira at gcc dot gnu.org, burnus at gcc dot gnu.org, jakub at gcc dot gnu.org, marxin at gcc dot gnu.org, tnfchris at gcc dot gnu.org Depends on: 109230 Target Milestone: --- Host: aarch64-linux-gnu Target: aarch64-linux-gnu +++ This bug was initially created as a clone of Bug #109230 +++ On aarch64 we optimize at -O2 only half of the following routines: typedef float V __attribute__((vector_size (4 * sizeof (float)))); typedef int VI __attribute__((vector_size (4 * sizeof (float)))); __attribute__((noipa)) V foo (V x, V y) { V a =3D x - y; V b =3D y + x; return __builtin_shuffle (b, a, (VI) { 0, 5, 2, 7 }); } __attribute__((noipa)) V bar (V x, V y) { V a =3D x - y; V b =3D y + x; return __builtin_shuffle (a, b, (VI) { 4, 1, 6, 3 }); } __attribute__((noipa)) V baz (V x, V y) { V a =3D x - y; V b =3D y + x; return __builtin_shuffle (b, a, (VI) { 4, 1, 6, 3 }); } __attribute__((noipa)) V qux (V x, V y) { V a =3D x - y; V b =3D y + x; return __builtin_shuffle (a, b, (VI) { 0, 5, 2, 7 }); } __attribute__((noipa)) V boo (V x, V y) { V a =3D x + y; V b =3D y - x; return __builtin_shuffle (b, a, (VI) { 0, 5, 2, 7 }); } __attribute__((noipa)) V corge (V x, V y) { V a =3D x + y; V b =3D y - x; return __builtin_shuffle (a, b, (VI) { 4, 1, 6, 3 }); } __attribute__((noipa)) V fred (V x, V y) { V a =3D x + y; V b =3D y - x; return __builtin_shuffle (b, a, (VI) { 4, 1, 6, 3 }); } __attribute__((noipa)) V garply (V x, V y) { V a =3D x + y; V b =3D y - x; return __builtin_shuffle (a, b, (VI) { 0, 5, 2, 7 }); } starting with r13-4024-gb2bb611d90d01f64a24 (plus r13-4122-g1bc7efa948f751 bugfix). The other half could be handled similarly, just with fneg+fsub rather than fneg+fadd. Unfortunately, match.pd canonicalizes those, we still have 0, 5, 2, 7 permutations for all of them, but the two operations swapped. Unfortunately match.pd doesn't allow :c on vec_perm, and if we use (for op (plus minus) otherop (minus plus) then we couldn't add :c to the plus one. So, copy and paste the whole large simplification, swap (plus:c @0 @1) and (minus @0 @1) and replace (plus at = the end with (minus? Or handle the commutativity manually? (for op (plus minus) otherop (minus plus) (simplify (vec_perm (op @0 @1) (otherop @2 @3) VECTOR_CST@4) and use operand_equal_p manually to allow all forms we want? Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109230 [Bug 109230] [13 Regression] Maybe wrong code for opus package on aarch64 s= ince r13-4122-g1bc7efa948f751=