From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 25BB9386184A; Sun, 20 Sep 2020 20:36:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 25BB9386184A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1600634166; bh=gX46Ue4nJFQsuz0+yJOET8BF0V2ItjuruD2U8T34nqg=; h=From:To:Subject:Date:From; b=ihN0tarQMKmonZmV599n0uqFsUyPu4XWYjpjzOQ/3Mho/74FCiXF98cWGbEWwOj/1 cVxu3SkHl1EKH26ZJZkTnm+E88UPNM/aX98qX35XNFLT1wyPjB3b0YqDa19pKs2x6C vygEkMHHlJpPWNUl4+xzikRdWOUA49WQM8SBMY2Q= From: "already5chosen at yahoo dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/97127] New: FMA3 code transformation leads to slowdown on Skylake Date: Sun, 20 Sep 2020 20:36:06 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: already5chosen at yahoo dot com 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 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 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: Sun, 20 Sep 2020 20:36:06 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97127 Bug ID: 97127 Summary: FMA3 code transformation leads to slowdown on Skylake Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: already5chosen at yahoo dot com Target Milestone: --- The following clever gcc transformation leads to generation of slower code = than non-transformed original: a =3D *mem; a =3D a + b * c; where both b and c are reused further down is transformed to: a =3D b a =3D *mem + a * c; Or, expressing the same in asm terms vmovuxx (mem), %ymmA vfnmadd231xx %ymmB, %ymmC, %ymmA transformed to vmovaxx %ymmB, %ymmA vfnmadd213xx (mem), %ymmC, %ymmA You may ask "Why transformed variant is slower?" and I can try my best to answer (my guess is that performance bottleneck is in rename stage rather t= han in the execution stage and transformed code occupies 3 rename slots vs 2 re= name slots by original) but it would be mostly pointless. What's matters that on Skylake the transformed variant is slower and I can prove it with benchmark. BTW, on Haswell too. You can see comparison of two variants at https://github.com/already5chosen/others/tree/master/cholesky_solver/gcc-ba= dopt-fma3 The interesting spot is starting at line 367 in file chol.cpp. Or starting two lines below .L21: in asm generated by gcc 10.2.0 (chol_a.s). Run 's_chol_a 100' vs 's_chol_b 100' and see the difference in favor of the second (de-transformed) variant. The difference, in this particular case, is small, order of 2-4 percents, b= ut very consistent. In more tight loops I would expect a bigger difference.=