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.

Compiler: whether the optimized program is correct



Tool/software: TI C/C++ Compiler

Look at the picture.

a=a*b+c*d;two ADDSP.L1 appear in assembly code ,why?isn't it two MPYSP and one ADDSP?

And the c=c*d+c*d;only one ADDSP appears.

I use the -O1 optimization level.i wonder if the optimized code is incorrect?

And i also want to know if i can  use .M1 and .M2 units at the same time,so i can  double the speed.(For example, a=b*c,d=e*f, two multiplication,whether i can use .M1 and .M2 units at same time to execute two multiplication at same time. If it is right ,please tell me how to achieve it.)

At last ,how to make the assembly code "| |"(paralled??).

Expect your reply!

  • user4756843 said:
    I use the -O1 optimization level.i wonder if the optimized code is incorrect?

    Without seeing the complete code not sure.

    The posted code shows the following expressions in the loop:

    a=a*b+c*d;
    c=c*d+c*d;

    Some possible explanations for why the compiler optimizer has generated correct code:

    1) The sub-expression c*d appears three times per loop, and the optimizer has recognized that and only performed the multiplication once per loop.

    2) If the value of b isn't changed during the loop, and b is initialized to two outside of the loop the optimizer could have validly replaced the sub-expression a*b with a+a.

    When you test the code by running it in the debugger, does the debugger show the correct values for the variables?

  • user4756843 said:
    I use the -O1 optimization level.

    This means the compiler does not use the single most important optimization for C6000, called software pipelining.  For that you need to use --opt_level=2 or higher.  (The equivalent short form options are -o2 or -O2.)  

    I recommend you build with -o3 -mw -s, then inspect the resulting assembly output.  It appears in a file with the same name as the source file, but the extension is .asm.  That is easier than looking at the disassembly in CCS.  For more information on these options, please see the wiki article C6000 Compiler: Recommended Compiler Options.

    Thanks and regards,

    -George