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.

bug found in host intrinsics, _sshvr and _sshvl

Other Parts Discussed in Thread: DM3730

Due to the restrictions of the licence, I guess I'm not supposed to post the source code in public.

But in ver0.91.00, file "C6xSimulator.c", function "int32 _sshvr(int32 a,int32 b)" and function int32 _sshvl(int32 a,int32 b).

In the host intrinsics implementation, if right shift > 31, then return=MAX_INT32 or MIN_INT32;

In spru732, those instructions are described as, if right shift >31, return = shifted value(usually 0);

Dehuan

  • I agree the logic in the instruction description in the CPU manual is a bit different from the C code in the host intrinsics implementation.  But it comes to the same thing.  Note that the host intrinsics implementation takes care of the special case where the input value to be shifted is 0.  If that input value is zero, then zero is returned.  Thus the code which returns MAX_INT32 or MIN_INT32 does not need to worry about the case where the input value is 0.  Since that value is non-zero, and it is shifted (left or right) 31 places, the result must be MAX_INT32 or MIN_INT32 after saturation.  

    That said, these things are tricky.  There could be some cases I am not considering.  Do you have a specific example where the hardware produces a different result than the host intrinsics implementation?

    Thanks and regards,

    -George

  • George

    Using host intrinsics, I get:

    _sshvr(1, 32)=MAX_INT32

    I have not tested it on the chip yet, but I'm expecting a 0 as result.
  • On C64X+(in DM3730), with cl6x v6.1.14, _sshvr(1, 32)=1.
    With host intrinsics 0.91, gcc 4.6 on linux x96, I got _sshvr(1, 32)=MAX_INT32.
  • I agree you have found a problem in the host intrinsics implementation of _sshvr and _sshvl.  Right shift by 31 or greater is incorrect.  Bug reports for this package are not maintained in SDOWP, but in another system which cannot be viewed outside TI.  I filed a report in that system.  

    I cannot think of a workaround.  I suspect the code for these intrinsics will be re-implemented from scratch.

    However, I'm not aware of any plans for an updated release of the host intrinsics package.  When the code is changed, I'll make sure the changes are published in this thread.

    Thanks and regards,

    -George