This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

_sshvl problem

Dear All,

I am asking about setting max and min value for _sshvl

here what I found in programmer guide

"Shifts src2 to the left/right of src1 bits. Saturates
the result if the shifted value is
greater than MAX_INT or less than
MIN_INT"

 

I made

#define MAX_INT 32567

#define MIN_INT -32568

 

and in the function i write

 

y = _sshvl( 6000 , 8)

and i still find y doesnt saturate to the max int i defined

 

any suggestions ?

 

  • We apologize for the confusion that was caused by the description in the Programmer's Guide. The terms MAX_INT and MIN_INT were intended to refer to the C6000 architecture's physical limits for the 32-bit argument of the sshvl instruction. The CPU and Instruction Set Reference Guide has the exact description of the way this instruction works, without the use of these confusing labels.

    The definitions you made for MAX_INT and MIN_INT are not used by the sshvl instruction.

    One way to get the saturation you seek would be

    y = _sshvl( 6000, 8+16 ) >> 16;

    Depending on datatypes and sign-extension, this might not be the right way. But the idea is to get the number of interest to saturate at +/- 2**31 then shift it back down to the 16-bit size.

    Please also look at the _sshl intrinsic. It is faster, but does not allow for a negative left-shift to be the same as a right-shift, so it is not identical to _sshvl. But _sshl does shift left and it does saturate.

     

    If this answers your question, please click the  Verify Answer  button below. If not, please reply back with more information.