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.

"Disqualified loop: Loop contains control code"

Hello,

I'm trying to optimize a short function for the C64x+:

#include "IQmath_inline_all.h"

void cw(int * restrict w, int wl, const int * restrict c, int nc, int b)
{
    int i, j, a;

    _nassert((int) w % 8 == 0);

#pragma MUST_ITERATE(0, 2, 1);
    for (j = 1; j < nc; j += 2) {
#pragma MUST_ITERATE(512, 51200, 512);
        for (i = 0, a = 0; i < (wl >> 1); ++i, a += j*b)
            *(w + i) -= _IQ30rsmpy(*(c + j), _IQ30cosPU(a));
    }
}

It uses the IQmath library (source code) and the two functions seem to get inlined. The compiler is part of the "C6000 Code Generation Tools 7.3.0" (CCS 4.2.4.00033). The following compiler options are used:

-mv64plus --symdebug:skeletal -O3 --define=xdc_target_types__=ti/targets/std.h --define=_INLINE_IQMATH --diag_warning=225 --debug_software_pipeline --optimizer_interlist --opt_for_speed=4 --gen_opt_info=2 --single_inline --gen_profile_info -k --src_interlist --preproc_with_compile

The problem is that, according to the .asm file, the loop does not get software pipelined. Instead, the following message is displayed:

Disqualified loop: Loop contains control code

What do I need to change to have the compiler software pipeline the loop? Where is the "control code" in the loop when both functions called are inlined ("inlineable" according to .nfo file)?

Thank you for your support.

  • Alex,

    I'm going to move this thread to the compiler forum.

    Regards,

    Dan

     

  • Are the functions actually inlined?  (Look for CALL instructions in the loop, in the .asm file.)  Do the inlined functions contain branches or ?: operators?  (Look for them in the .asm file too.)

  • Thank you for your reply.

    I was not able to find any CALL instructions or ? : operators in the .asm file.

    However, I did find the following (taken from the .asm file as well):

       [ A0]   BNOP    .S1     $C$L1,2           ; |10|
               ; BRANCHCC OCCURS {$C$L3}         ; |12|

    If the code cannot be software pipelined because of _IQ30rsmpy and _IQ30cosPU, then what other options do I have to improve the above code?

  • I am able to reproduce what you see.  However, I had to change #include "IQmath_inline_all.h" to #include "IQmath_inline.h".  I don't have a file named IQmath_inline_all.h in my installation of the IQmath package.  I installed the latest version from here.

    I also see the message: Disqualified loop: Loop contains control code.  The function underlying the macro _IQ30rsmpy is inlined.  It contains some if statements that become branches in the generated assembly.  These branches are the control code that disqualifies the loop from being software pipelined.

    But that is not the main reason the loop will not pipeline.  The code for IQ30cosPU is not inlined, and thus a function is called.  The function underlying the macro _IQ30cosPU is _IQNcosPU.  For the compiler to inline a function, it has to see the full definition of the function (i.e. all of the source for it).  This is not present anywhere in the IQmath header files.  One way to see this ... Build again with the option --preproc_with_comment and inspect the resulting .pp file.  Then search for _IQNcosPU.  You can find declarations of it, but not the full definition.

    Thanks and regards,

    -George 

  • Thank you for your reply, George.

    I received the C64x+ IQMath source code (file named "IQmath Souce Release-2.1.3-Setup.zip", including "IQmath_inline_all.h") from a TI employee after having submitted a request through the link you provided in your message. The code therefore contains the entire definition of the function _IQNcosPU, as can be confirmed with the .pp output.

    I understand from your message that, even if _IQNcosPU was inlined, the loop will not get software pipelined because of "if" statements in the function underlying _IQ30rsmpy. Does that imply a lack of other options to significantly improve the execution speed of the loop?

  • Some if statements can "converted" by the compiler so that the loop can be software pipelined.  This basically involves predicating each instruction in the "if" or "if then else" statement.  However, if the if statements are nested within other if statements, or if the "if" condition is sufficiently complex, the compiler may not be able to "convert" the if statement.

  • Hi, Alex

         Have you finished optimization?  I'm working on optimizing now, there is some IQmath function calling in several loops  of my code. I read the compiler feedback information, those loops are disqualified loops( because function call occur in loops ), and the compiler failed to do software pipelining. I'm wondering if your optimization is successful with inlining certain IQmath functions. Did the performance of your code improve remarkably with inlining IQmath ?

       ps: I have sent IQmath source code request, and I'm waiting for it. The source code