[PATCH][X86] __builtin_ctz/clz sometimed defined for zero input

Sean Silva chisophugis at gmail.com
Mon Oct 27 16:18:28 PDT 2014


Why not just

-  return __builtin_clzs(__X);
+  return (__X == 0 ? 16 : __builtin_clzs(__X));

and corresponding changes in the other functions in lzcntintrin.h

(+ the test changes)

Adding new builtins adds a maintenance and documentation burden.

-- Sean Silva

On Mon, Oct 27, 2014 at 4:05 PM, Robinson, Paul <
Paul_Robinson at playstation.sony.com> wrote:

>  New patch attached that defines new builtins and uses them in
> lzcntintrin.h.  This patch doesn't change anything about the behavior of
> the old builtins (although they come along for the ride when I refactored
> the CGBuiltins.cpp implementation).  I also tightened up the test for the
> lzcntintrin.h functions, as it didn't notice the incorrect translation.
>
> Yeah I know I should have a doc update as well; I'll get to it, but I have
> to leave right now.
>
> --paulr
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141027/c03c3f2b/attachment.html>


More information about the cfe-commits mailing list