Tool News
 
 
 

Tool News

Products Info
Downloads
Tools FAQs
MAEC TOOL NEWS: MAECT-M3T-CC32R-011101D

M3T-CC32R
Precaution

Please take note of the following problems in using cross-tool kit M3T-CC32R for the M32R family MCUs:
  • On optimizing members of an array in a structure or union declared to be volatile
  • On optimizing programs in which shift or mask operations are performed after referencing variables of type unsigned short


  1. Problem on Optimizing Members of an Array in a Structure or Union Declared to Be Volatile
    1.1 Versions Concerned
    M3T-CC32R V.1.00 Release 1 -- V.3.10 Release 1

    1.2 Description
    When members of an array are contained in a structure or union declared to be volatile, optimization covering the -02 or -04 option will make the volatile attribute of the above members ineffective.
    (That is, the volatile attribute loses its effect in the multiple accesses described in condition (4) in the following section, and the compiler will simply remove all the accesses except the last one from the program.)

    1.3 Conditions
    This problem will occur if the following seven conditions are satisfied:
    (1) An optimizing option covering -O2 or -O4 is used (any of the following options is selected: -O2, -O3, -O4, -O5, -O6, -O7, -Otime only, and -Ospace only).
    (2) A structure or union is declared to be volatile.
    (3) There exist members of an array that have not been declared to be volatile in the structure or union in (2) above.
    (4) One of the members of the array in (3) above is accessed two or more times successively (referenced or assigned more than once or referenced after assigned).
    (5) In the accesses in (4) above, any assignment is made prior to its reference.
    (6) No function calls are made during the multiple accesses in (4).
    (7) Neither of the following assignments is performed during the multiple accesses in (4):
    (a) any assignment to an array indexed with a variable
    (b) any assignment of a global variable

    1.4 Example
    [Source file "sample.c"]
    --------------------------------------------------------------------
    extern volatile struct {  /* Condition (2) */
        short data[30];       /* Condition (3) */
    } input;
    
    long
    func(int arg)
    {
        short data1, data2;
        data1 = input.data[0];  /* Conditions (4) and (5) */
                                /* Conditions (6), (7a), and (7b) */
        data2 = input.data[0];  /* Conditions (4) and (5) */
    
        return data1 + data2;
    }
    --------------------------------------------------------------------
    
    [Example of typing a command in CC32R (a % sign denotes a prompt)]
    --------------------------------------------------------------------
    % cc32R -c -O2 sample.c
    --------------------------------------------------------------------
    1.5 Workaround
    This problem will be circumvented in any of the following three ways:
    (1) Suppress optimization in the -O2 and -O4 levels.
    Optimization covering the -O4 option is performed when optimizing option -O4, -O5, -O6, -O7, -Otime only, or -Ospace only has been selected. Also, optimization covering the -O2 option is done when optimizing option -O2, -O3, -O6, -O7, -Otime only, or -Ospace only has been used. If you want to use -Otime or -Ospace, select either -O0 or -O1 at the same time.
    (2) Declare the members of the array concerned to be volatile.
    [Modified example of source file "sample.c"]
    -------------------------------------------------------------------
     extern volatile struct {
         volatile short data[30];  /* Declared to be volatile */
     } input000;
    -------------------------------------------------------------------
    1.6 Schedule of Fixing the Problem
    We plan to fix this problem in our next release.



    M3T-CC32R Precaution
    MAECT-M3T-CC32R-011101D

  2. Problem on Optimizing Programs Where Shift or Mask Operations Are Performed after Referencing Variables of Type Unsigned Short
    2.1 Version Concerned
    M3T-CC32R V.3.10 Release 1

    2.2 Description
    When shift or mask (bitwise-AND with a constant) operations are performed after referencing a variable of type unsigned short, optimization covering the -O1 option will result in incorrect code being generated for those operations.
    (That is, the compiler will select an improper register to generate incorrect code at each operation in condition (3) in the following section.)

    2.3 Conditions
    This problem will occur if the following five conditions are satisfied:
    (1) An optimizing option covering -O1 is used (any of the following options is selected: -O1, -O3, -O5, -O7, -Otime only, and -Ospace only).
    (2) A variable of type unsigned short is referenced.
    (3) After the reference in (2) above is described any of the following operations:
    (a) A bitwise AND operation with a constant (& 0xff etc.) after the right shift of the constant (>> 8 etc.)
    (b) A type cast operation of a constant to short or char after the right shift of the constant (>> 8 etc.)
    (c) A bitwise AND operation with a constant (& 0xff etc.)
    (4) The operations of (2) and (3) are described in the same processing block (between two places at which the current flow of processing will be changed by branch or loop statements).
    (5) The value referenced in (2) is held as it is until after (3).

    2.4 Example
    [Source file "sample.c"]
    --------------------------------------------------------------------
    extern void func(unsigned char);
    
    unsigned short var1;
    unsigned int   var2;
    
    unsigned short foo(void)
    {
            unsigned int use_later;
            use_later = var1;            /* Condition (2) */
              /*   :                     /* Condition (5) */
              /*   : (In these lines exist no assignments to use_later) */
            func(var2 >> 16);            /* Conditions (3)(b) and (4) */
            return use_later;
    }
    --------------------------------------------------------------------
    
    [Example of typing a command in CC32R (a % sign denotes a prompt)]
    --------------------------------------------------------------------
    % cc32R -c -O1 sample.c
    --------------------------------------------------------------------
    2.5 Workaround
    This problem will be circumvented in any of the following three ways:
    (1) Suppress optimization in the -O1 level.
    Optimization covering the -O1 option is performed when optimizing option -O1, -O3, -O5, -O7, -Otime only, or -Ospace only has been selected. If you want to use -Otime or -Ospace, select any of those options, -O0, -O2, -O4, and -O6, at the same time.
    (2) Divide the processing block concerning conditions (2) and (3) into two.
    [Modified example of source file "sample.c"]
    -------------------------------------------------------------------
    extern void func(unsigned char);
    
    unsigned short var1;
    unsigned int   var2;
    
    unsigned short foo(void)
    {
            unsigned int use_later;
            while (1) {
                use_later = var1;
                break;
            }                 /* Here the block is divided into two */
            func(var2 >> 16);
            return use_later;
    }
    -------------------------------------------------------------------
    (3) Declare the variable to be other than unsigned short.
    [Modified example of source file "sample.c"]
    -------------------------------------------------------------------
    extern void func(unsigned char);
    
    unsigned long  var1;  /* Declared to be unsigned long, 
                                             not unsigned short */
    unsigned int   var2;
    
    unsigned short foo(void)
    {
            unsigned int use_later;
            use_later = var1;
            func(var2 >> 16);
            return use_later;
    }
    -------------------------------------------------------------------
    2.6 Schedule of Fixing the Problem
    We plan to fix this problem in our next release.




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