From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 57BF3386F820; Fri, 5 Mar 2021 09:50:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 57BF3386F820 From: "jakub 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: Fri, 05 Mar 2021 09:50:29 +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: jakub 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 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: Fri, 05 Mar 2021 09:50:29 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99396 --- Comment #8 from Jakub Jelinek --- so using __unsigned_type =3D __make_unsigned<_Tp>::__type; constexpr auto _Nd =3D __gnu_cxx::__int_traits<__unsigned_type>::__di= gits; const auto __r =3D static_cast(__s); const auto __y =3D static_cast<__unsigned_type>(__x; const auto __z =3D (__y << (__r % _Nd)) | (__y >> ((-__r) % _Nd)); return static_cast<_Tp>(__z); ? Of course, if _Tp can be anything other than integral types, it would ne= ed to be a specialization for integral types (though it will work for __int128 fine if that doesn't count as integral).=