[PATCH] D50168: [Builtins] Implement __builtin_clrsb to be compatible with gcc

Sanjay Patel via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 8 06:21:26 PDT 2018


spatel added a comment.

About the bit hacking: I don't think clang should be in the optimization business. We should be able to take the most obvious/simple representation for this builtin and reduce it as needed (either in instcombine or the backend). So it would be better to use the version with the subtract rather than shift/or. That version corresponds more directly to the code in APInt::getMinSignedBits()?



================
Comment at: include/clang/Basic/Builtins.def:416
 BUILTIN(__builtin_popcountll, "iULLi", "nc")
+BUILTIN(__builtin_clrsb  , "ii"  , "nc")
+BUILTIN(__builtin_clrsbl , "iLi" , "nc")
----------------
Is is intentional that clang doesn't document the behavior of the builtins that it copies from gcc? I'd think logic descriptions for all of these would be handy, but especially for less common ones like 'clrsb'.


https://reviews.llvm.org/D50168





More information about the cfe-commits mailing list