From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 81C08388C025; Sat, 6 Mar 2021 10:12:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 81C08388C025 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/99396] std::rotl and std::rotr Does not convert into ROTATE on the gimple level Date: Sat, 06 Mar 2021 10:12:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub 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 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: Sat, 06 Mar 2021 10:12:49 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99396 --- Comment #19 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:84185598dc7470bad4e7f8c22b64e3c944efb670 commit r11-7542-g84185598dc7470bad4e7f8c22b64e3c944efb670 Author: Jakub Jelinek Date: Sat Mar 6 11:11:30 2021 +0100 libstdc++: Improve std::rot[lr] [PR99396] As can be seen on: unsigned char f1 (unsigned char x, int y) { return std::rotl (x, y); } unsigned char f2 (unsigned char x, int y) { return std::rotr (x, y); } unsigned short f3 (unsigned short x, int y) { return std::rotl (x, y); } unsigned short f4 (unsigned short x, int y) { return std::rotr (x, y); } unsigned int f5 (unsigned int x, int y) { return std::rotl (x, y); } unsigned int f6 (unsigned int x, int y) { return std::rotr (x, y); } unsigned long int f7 (unsigned long int x, int y) { return std::rotl (x, y); } unsigned long int f8 (unsigned long int x, int y) { return std::rotr (x, y); } unsigned long long int f9 (unsigned long long int x, int y) { return std::rotl (x, y); } unsigned long long int f10 (unsigned long long int x, int y) { return std::rotr (x, y); } //unsigned __int128 f11 (unsigned __int128 x, int y) { return std::rotl= (x, y); } //unsigned __int128 f12 (unsigned __int128 x, int y) { return std::rotr= (x, y); } constexpr auto a =3D std::rotl (1234U, 0); constexpr auto b =3D std::rotl (1234U, 5); constexpr auto c =3D std::rotl (1234U, -5); constexpr auto d =3D std::rotl (1234U, -__INT_MAX__ - 1); the current definitions of std::__rot[lr] aren't pattern recogniz= ed as rotates, they are too long/complex for that, starting with signed modulo, special case for 0 and different cases for positive and negative. For types with power of two bits the following patch adds definitions t= hat the compiler can pattern recognize and turn e.g. on x86_64 into ro[lr][bwlq] instructions. For weirdo types like unsigned __int20 etc. it keeps the current definitions. 2021-03-06 Jakub Jelinek PR libstdc++/99396 * include/std/bit (__rotl, __rotr): Add optimized variants for power of two _Nd which the compiler can pattern match the rotates.=