From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E75703858D1E; Fri, 5 Jan 2024 21:03:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E75703858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704488639; bh=n/5h/QSHOSMt6t3auwxMJDRZwI6mGNY/ry8IOIqFJH8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=n9o/pJ+9YzMVVEDsAjmUT7HGBz+pPY0a12bnz4z0SxwOg+gJgB5b4PsvR+hgWGCwr 5cGnoT0u92nb3yIoXYC03eqwVF2gpxPALK5Eitpz6tbCpR/SJ9dCcmIEQad47ejcZ1 rTLldyGjHTzau7oAEeoDrtBAbbmx9gFXBl9xrECA= From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/113235] SMHasher SHA3-256 benchmark is almost 40% slower vs. Clang (not enough complete loop peeling) Date: Fri, 05 Jan 2024 21:03:59 +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: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka 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: 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=3D113235 --- Comment #6 from Jan Hubicka --- The internal loops are: static const unsigned keccakf_rotc[24] =3D { 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14, 27, 41, 56, 8, 25, 43, 62, 1= 8, 39, 61, 20, 44 };=20 static const unsigned keccakf_piln[24] =3D { 10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4, 15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1 }; static void keccakf(ulong64 s[25]) {=20=20 int i, j, round; ulong64 t, bc[5]; for(round =3D 0; round < SHA3_KECCAK_ROUNDS; round++) { /* Theta */ for(i =3D 0; i < 5; i++) bc[i] =3D s[i] ^ s[i + 5] ^ s[i + 10] ^ s[i + 15] ^ s[i + 20]; for(i =3D 0; i < 5; i++) {=20 t =3D bc[(i + 4) % 5] ^ ROL64(bc[(i + 1) % 5], 1); for(j =3D 0; j < 25; j +=3D 5) s[j + i] ^=3D t; } /* Rho Pi */ t =3D s[1]; for(i =3D 0; i < 24; i++) { j =3D keccakf_piln[i]; bc[0] =3D s[j]; s[j] =3D ROL64(t, keccakf_rotc[i]); t =3D bc[0]; } /* Chi */ for(j =3D 0; j < 25; j +=3D 5) { for(i =3D 0; i < 5; i++) bc[i] =3D s[j + i]; for(i =3D 0; i < 5; i++) s[j + i] ^=3D (~bc[(i + 1) % 5]) & bc[(i + 2) % 5]; } s[0] ^=3D keccakf_rndc[round]; } } I suppose with complete unrolling this will propagate, partly stay in regis= ters and fold. I think increasing the default limits, especially -O3 may make se= nse. Value of 16 is there for very long time (I think since the initial implementation).=