C6000 compiler does not implement return value optimization (RVO)

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Implemented
    • Priority: 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.

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

              Created:
              Updated:
              Resolved:

                Connection: Intermediate to External PROD System
                EXTSYNC-2261 - C6000 compiler does not implement r...
                SYNCHRONIZED
                • Last Sync Date: