What's New in C++Builder 10.2: Part 2 - Code Generation

Posted by on in Blogs

RAD Studio 10.2 Tokyo will be out very soon, and I'd like to let you know some of what you can expect to see new on the C++Builder side.  While the majority of work is for Linux, which will be available for C++ in 10.2.1, we've worked on three key areas:

Today I want to discuss what's new for code generation.

Optimization Levels - new and faster!

In all previous versions of C++Builder, going back to when the classic compiler was the only compiler, there were only three optimization levels, counting 'none' as an option:

  • None: -O0 (used for debugging)
  • Generate smallest possible code: -O1
  • Generate fastest possible code: -O2

Although these use the -On compiler flag that's traditional for all C++ compilers, in the past these were not labeled with an 'O' flag in the IDE description. Optimization descriptions are tricky, and especially with the Clang compilers map to a variety of different options. 'Generate smallest', for example, could also be 'Prefer smaller code' or 'Optimize for size' or similar.  Some IDEs don't even try to describe the options, just give the number, but it's generally understood a higher optimization level usually results in faster code.

In C++Builder 10.2, we are adding a fourth level, -O3:

  • Generate most optimized code (-O3)

For the Clang-enhanced compilers, this matches -O3 for other compilers, and adds vectorisation and inlining above O2.  (For classic bcc32 this maps to -O2.)

As with any optimisation flag, you need to test the results with your own code. However, for some internal tests, -O3 gives speed improvements of up to twice the performance of -O2. We suggest that for release builds, you will usually want to build with either -O2 or -O3 and you may see large improvements for -O3.

O1 and O2

We have also addressed several code generation issues at these levels. Even if you don't take advantage of -O3, your code will be more robust in 10.2.

Future

Adding a new optimization level, or other optimization or compiler flags, is a lot of work: it involves heavy testing and fixing many small and unusual corner cases, in both the compiler and linker.  We are pleased to offer -O3 since performance is important to C++ customers.

We're looking into what other performance-related changes we can make in future, and nothing is off the table. Your feedback here would be appreciated in order to deliver the best compiled code performance that you need. Meanwhile, in 10.2, we hope you enjoy your faster -O3 code!



About
Gold User, No rank,
C++ Product Manager, looking after C++Builder as well as the IDE.

Comments

  • Per Sverre H24677
    Per Sverre H24677 Sunday, 7 May 2017

    For bcc32c:
    - Do you have any plans to support more SIMD instruction (SSE3/4,AVX,FMA,...) using intrinsics?
    - Do you have any plans to support "aligned" attribute, i.e. memory aligning of variables?
    Newer versions of clang-compiler seems to support these, so why not add these features as well?

  • David Millington
    David Millington Monday, 22 May 2017

    We would certainly like to. We are upgrading to newer versions of Clang, so features like that will be possible as we roll out the updated toolchain.

  • Chris GW
    Chris GW Wednesday, 29 March 2017

    Great to see continued improvements in C++. I'm hoping the very slow C++ trigonometric performance (https://quality.embarcadero.com/browse/RSP-11166) and C++ code insight IDE lockups (https://quality.embarcadero.com/browse/RSP-13877) can be addressed soon.

  • David Millington
    David Millington Monday, 10 April 2017

    They're on the list :)

  • OliWe
    OliWe Tuesday, 21 March 2017

    The linker and compiler improvements sound very good.
    Is the CMAKE compatibility of bcc64 improved in 10.2?

  • David Millington
    David Millington Tuesday, 21 March 2017

    Glad you like them.

    We haven't made any CMake changes in 10.2.0. It's still on the roadmap though.

  • Please login first in order for you to submit comments
  • Page :
  • 1

Check out more tips and tricks in this development video: