Norm is an intrinsic generally used in all the DSP processors. It calculates the number of bits which are of same as of sign bits.
For example, if the processor has 32 bit number say, int x.
x =19; // 19 in binary will be 0x00000013
and now I do norm(x) on TI DSP it gives the the shift count as 26. This 26 tells me how much this number can be left shifted.
Is there any such instruction available in AMD opteron machine?
I am not aware of Norm.
We have a function called PopCount in opencl which retruns number of non zero bits in the given binary number.
Please check opencl spec section 6.12.3 Integrer Functions.
I have found one which is LZCNT. There is also another BSR.
LZCNT tells the number of leading zeros.
norm(x) can be written as LZCNT(a,x)-1. This is as per the amd doc of general purpose and system instructions.
Also, one can use builtin_clz function of gcc to get leading zeros count, if you are writing code in C
Thanks for posting back your findings. It sure is going to help someone someday...
btw.. Will "LZCNT" work with -ve numbers. Since -ve numbers are nothing but 2's complement, there will be no leading zeroes mostly....That will give you 0 and subtracting 1 will give you -1.. oops... Or.. Did I misunderstand something here?
Is LZCNT sign aware?