From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EB91D3858C60; Mon, 20 Dec 2021 05:27:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EB91D3858C60 From: "crazylht at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/103750] [i386] GCC schedules KMOV instructions that destroys performance in loop Date: Mon, 20 Dec 2021 05:27:38 +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: 12.0 X-Bugzilla-Keywords: missed-optimization, ra X-Bugzilla-Severity: normal X-Bugzilla-Who: crazylht at gmail 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: attachments.created 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: Mon, 20 Dec 2021 05:27:39 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103750 --- Comment #13 from Hongtao.liu --- Created attachment 52031 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D52031&action=3Dedit untested patch. Attached patch can optimize #c0 to vmovdqu (%rdi), %ymm1 vmovdqu16 32(%rdi), %ymm2 vpcmpuw $0, %ymm0, %ymm1, %k1 vpcmpuw $0, %ymm0, %ymm2, %k0 kmovw %k1, %k2 kortestw %k0, %k1 je .L10 and #c6 to .L4: vmovdqu (%rdi), %ymm2 vmovdqu 32(%rdi), %ymm1 vpcmpuw $0, %ymm0, %ymm2, %k3 vpcmpuw $0, %ymm0, %ymm1, %k0 kmovw %k3, %k1 kmovw %k0, %k2 kortestd %k2, %k1 je .L10 It should be much better than orginal version, but still a little suboptima= l: the frist kmovw should be sinked to the exit edge, the latter 2 kmovw shoul= d be emilated.=