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.

How to use long __lmax(long dst, long src) in CCS platform

Hello all,

I'm working on a logic where I would like to use of conditional operator for saturation part as the below document suggests C2000 uses a special type of instruction in using a conditional operations for saturation.

C2000 Performance Tips and Tricks

Images of the above link for usage of Conditional operator is as shown below.

However, though I use the conditional operator, I don't see any change in the assembly as those images are attached below.

  

Also, I found the below link which suggests using long __lmax(long dst, long src); helps in executing saturation example with instructions MAXL ACC, src.hi32 MAXCUL P, src.lo32 & therefore I feel there will be reduction in the clock cycles.

TMS320C28x Optimizing C/C++ Compiler v18.1.0.LTS User's Guide (Rev. P)

Here Comes the cquestion, I I'm using the long __lmax(long dst, long src); it is throwing the error. Kindly help in using the appropriate method in using the instruction long __lmax(long dst, long src); 

Thanks in advance,

Raju.

  • Hello all,

    I used var1=100 & var2=0 and tried below intrinsics which didn't throw any error. As per this, the compiler should assign var1=0;

          __lmin(var1 , var2 );     // If src < dst, copy src to dst

    But when I try to debug, it is not stopping at that line, instead it's skipping that line resulting in there is no change in the values.

     

    Any help would be appreciated,

    Thanks in advance,

    Raju

  • Please submit two test cases.  One for when ...

    though I use the conditional operator, I don't see any change in the assembly as those images are attached below

    The other for when ...

    I'm using the long __lmax(long dst, long src); it is throwing the error

    In each case, for the source file that contains the problem code, please follow the directions in the article How to Submit a Compiler Test Case.

    Regarding ...

    I'm using the long __lmax(long dst, long src); it is throwing the erro

    When does this error occur?  When building?  When running the code? If it is when running the code, please describe what you see in detail.

    Thanks and regards,

    -George

  • I'd appreciate a third test case, this time for when ...

    I used var1=100 & var2=0 and tried below intrinsics which didn't throw any error. As per this, the compiler should assign var1=0;

          __lmin(var1 , var2 );     // If src < dst, copy src to dst

    Thanks and regards,

    -George

  • Hi George,

    Thanks for responding to my query.

    Initially I tried using conditional operator & there is no difference. You can observe the same disassembly code in both the figures as shown below.

     

     With Conditional Operator 

     

    If else loop

     

     

    Finally, the below syntax worked for me. In fact I forgot to assign the return operator of __lmin Intrinsic.

    var2 = __lmin( var1,var2 );

    But I surprised that the conditional operator didn't work.

    Thanks for your reply,

    Raju

  • I'm glad you found a solution.  But because you did not submit a test case, I still do not understand the original problem, and thus I do not understand why your solution works.

    Thanks and regards,

    -George

  • Hi George,

    In fact I'm using the model based design & then debugging the file by loading the files directly & checking whether that part of the code can be optimized.

    That's the reason why I could able to provide the test case.

    Thanks,

    Raju