Tool News
 
 
 

Tool News

Products Info
Downloads
Tools FAQs
RENESAS TOOL NEWS on October 16, 2008: 081016/tn6

A Note on Using the C/C++ Compiler
package--M3T-CC32R--
for the M32R MCU Family
--With Performing Float-Type Multiplication and Subtraction--


Please take note of the following problem in using the C/C++ compiler package--M3T-CC32R--for the M32R MCU family:
  • With performing float-type multiplication and subtraction


1. Product and Versions Concerned
   The C/C++ compiler package--M3T-CC32R--for the M32R MCU family 
     V.4.00 Release 1 through V.5.01 Release 00

2. Description
   If the -m32re5 and -fminst options, which enables using of the FMSUB 
   instruction, and an optimizing option are selected in compilation, an
   incorrect operand of the FMSUB instruction may be generated for the
   operations consisting of multiplication and subtraction both of 
   type float.

2.1 Conditions
    This problem may occur if the following conditions are all satisfied:
    (1) The -m32re5 and -fminst options are both selected in compilation.
    (2) The optimizing option used in compilation is either of the 
        following:
        (a) Any of the options -O, -O1, -O3, -O5, and -O7
        (b) Either -Ospace or -Otime with none of the options -O0, -O2, 
           -O4, and -O6 being selected.
    (3) The following float-type operations are both performed:
        (a) A multiplication whose both terms are of type float
        (b) A subtraction where a value of type float is subtracted from 
            the result of (a)
    (4) The subtraction in (3)-(b) refers to the auto variable to which 
        the result in (3)-(a) is assigned.

2.2 Examples
    Source code (sample.c):
    -------------------------------------------------------------------
    float A, B, C;
    float func(void)
    {
        float var;
        float answer;
        . . . . . . .
        var = A * B;         /* Condition (3)-(a) */
        answer = var - C;    /* Conditions (3)-(b) and (4) */
        . . . . . . .
    }
    -------------------------------------------------------------------

    In the above example, the problem may not occur depending on the 
    content of the code written in the omitted lines.

    Command line:
    -------------------------------------------------------------------
    cc32R -c -O7 -m32re5 -fminst sample.c    (Conditions (1) and (2))
    -------------------------------------------------------------------

    In the above example of source code, the correct expression for 
    calculating "answer" is A * B - C. However, in the case when the 
    problem arises, an incorrect instruction "FMSUB A,B,C" is generated, 
    which means A - B * C.

3. Workaround
   To avoid generating incorrect FMSUB instructions, compile the source 
   program by using the internal control option -Qa-Xs16.

    Example of command line:
    -------------------------------------------------------------------
    cc32R -c -O7 -m32re5 -fminst -Qa-Xs16 sample.c
    -------------------------------------------------------------------



© 2008. Renesas Technology Corp., All rights reserved. Privacy | Legal