Uploaded image for project: 'Embedded Software & Tools'
  1. Embedded Software & Tools
  2. EXT_EP-9755

C6000 compiler does not implement return value optimization (RVO)

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Implemented
    • Icon: Medium Medium
    • Code Generation Tools
    • CODEGEN-7364
    • Hide
      C6000_8.3.4
      C6000_7.4.24
      Show
      C6000_8.3.4 C6000_7.4.24
    • default
    • None automatic. The customer did the transformation by hand to compensate.
    • The compiler didn't do return-value optimisation (copy elision) in cases like the classic two-operand operator+(). The effect is an extra copy and an extra temporary variable.

      The attached test case files create a class that contains floating point arrays, and does addition and subtraction operations on those arrays. When results are returns from the add and subtract operations, they are copied from a local to the result location. Instead, the result location should be directly operated on.

      To build ...

      % cl6x -@options.txt --symdebug:none -s main.cpp matrix2.cpp
      

      Inspect the resulting assembly files. For the add operation in matrix2.asm, this compiler generated comment appears ...

      ;** 639	-----------------------    (*$P$T0).alloc = *(struct Matrix3x3::_Alloc *)&result;  // [3]
      

      This is the copy which should be avoided.

            syncuser TI User
            syncuser TI User
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: