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

Robinson, Paul Paul_Robinson at playstation.sony.com
Mon Oct 27 17:02:47 PDT 2014


That makes lzcntintrin.h completely pointless.  They'd just be alternate names for the functions in Intrin.h.
--paulr

From: Sean Silva [mailto:chisophugis at gmail.com]
Sent: Monday, October 27, 2014 4:18 PM
To: Robinson, Paul
Cc: Arthur O'Dwyer; cfe-commits at cs.uiuc.edu
Subject: Re: [PATCH][X86] __builtin_ctz/clz sometimed defined for zero input

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<mailto: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/20141028/e63de9c2/attachment.html>


More information about the cfe-commits mailing list