Intel documents _lzcnt_u32/64 as returning operand size for 0 input. Ditto 
tzcnt.  Here's the lzcnt reference:
https://software.intel.com/sites/products/documentation/doclib/iss/2013/compiler/cpp-lin/GUID-67C6440B-D49E-4D7C-98A2-667E47ED63CC.htm

These seem reasonable to support when compiling and targeting a microarch with 
support for the instructions.

The Intel documentation does not suggest any such restriction.  Currently the 
only Clang support is in Intrin.h, which we can live with.
Microsoft documentation claims that __lzcnt* returns the operand size for 0 
input, while noting "If you run code that uses this intrinsic on hardware that 
does not support the lzcnt instruction, the results are unpredictable."
http://msdn.microsoft.com/en-us/library/vstudio/bb384809(v=vs.100).aspx

While if we absolutely must due to compatibility, I would push hard to not 
support these functions unless targeting such hardware.

I find this particularly important because in the grander scheme of things 
*very little* x86 hardware in the world has lzcnt, and even less tzcnt. =[ Weak 
APIs like this seem really problematic there.

Hardware that Sony cares about does support these instructions, so, yeah, we 
want this.  The existing lzcntintrin.h requires __LZCNT__ defined, which 
subsets this into the hardware we care about, so…
--paulr

From: Chandler Carruth [mailto:[email protected]]
Sent: Monday, October 27, 2014 9:38 PM
To: Robinson, Paul
Cc: Richard Smith; Sean Silva; [email protected]
Subject: Re: [PATCH][X86] __builtin_ctz/clz sometimed defined for zero input


On Mon, Oct 27, 2014 at 9:16 PM, Robinson, Paul 
<[email protected]<mailto:[email protected]>> 
wrote:
I can't find any documentation *at all* for lzcntintrin.h, so I can find no 
suggestion that its __lzcnt* functions would have defined behavior on an input 
of 0.

I think it's not the exact header so much as the functions themselves that we 
should care about.

Intel documents _lzcnt_u32/64 as returning operand size for 0 input. Ditto 
tzcnt.  Here's the lzcnt reference:
https://software.intel.com/sites/products/documentation/doclib/iss/2013/compiler/cpp-lin/GUID-67C6440B-D49E-4D7C-98A2-667E47ED63CC.htm

These seem reasonable to support when compiling and targeting a microarch with 
support for the instructions.


Microsoft documentation claims that __lzcnt* returns the operand size for 0 
input, while noting "If you run code that uses this intrinsic on hardware that 
does not support the lzcnt instruction, the results are unpredictable."
http://msdn.microsoft.com/en-us/library/vstudio/bb384809(v=vs.100).aspx

While if we absolutely must due to compatibility, I would push hard to not 
support these functions unless targeting such hardware.

I find this particularly important because in the grander scheme of things 
*very little* x86 hardware in the world has lzcnt, and even less tzcnt. =[ Weak 
APIs like this seem really problematic there.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to