From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 59919384D15A; Thu, 6 Oct 2022 06:03:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 59919384D15A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665036188; bh=85peWRSPJLV5AGlGethsBaOW4bBgA4mcWDsipIgTUJ0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=beVkyfPRyiXfgDqWsXyR9eeUpSvStf54ZJj4nSzXA5bQv/odouiSUZ6jd2Oqxv94n AvYgpB5v9bBrdh0+XuWoisPkdPtJKjz9Vp01gnYfn9KVzWy2YbVNgBbK5BcGxBbmjt I0qYomI+mxrS0YdQaiNurAaIzl9keDtPdOAq3y2Q= From: "unlvsur at live dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/107167] It looks like GCC wastes registers on trivial computations when result can be cached Date: Thu, 06 Oct 2022 06:03:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: unlvsur at live 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: 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=3D107167 --- Comment #3 from cqwrteur --- (In reply to Andrew Pinski from comment #1) > This is a reassociation, scheduling issue and register allocation issue. >=20 > Plus your example might be slower due to dependencies. >=20 > Without a full example of where gcc ra goes wrong, gcc actually produces > much better code for this example due to register renaming in hw. > Note many x86_64 also does register renaming for the stack too https://github.com/openssl/openssl/blob/a8572674f12ceb39f7e66ccbaa8918b922c= 76739/crypto/sha/asm/sha512-x86_64.pl#L16 They mentioned that before. 40% improvement over compiler-generated code. "I really wonder why gcc # [being armed with inline assembler] fails to generate as fast code." # sha256/512_block procedure for x86_64. # # 40% improvement over compiler-generated code on Opteron. On EM64T # sha256 was observed to run >80% faster and sha512 - >40%. No magical # tricks, just straight implementation... I really wonder why gcc # [being armed with inline assembler] fails to generate as fast code. # The only thing which is cool about this module is that it's very # same instruction sequence used for both SHA-256 and SHA-512. In # former case the instructions operate on 32-bit operands, while in # latter - on 64-bit ones. All I had to do is to get one flavor right, # the other one passed the test right away:-)=