IBM XL C/C++ equivalent to #pragma GCC optimize

379 views Asked by At

We are experiencing bad code generation for a source file using IBM XL C/C++ at -O3 on PowerPC platforms. Its surfaces as a hang and it appears a particular loop is not broken.

The problem only surfaces under XL C/C++. Our testing regime indicates the source file is clean of undefined behavior, memory errors and other errata. We also don't receive strict/nostrict warnings from the compiler for the source file.

We want to compile the source file at -O2 instead of -O3. We want to add instrumentation, like a pragma, to the source file so it can be guarded appropriately for the compiler. The instrumentation allows others to wire-in other build systems like Cmake and Autotools and things will "just work" for them. (The necessary information is available in the source and not our makefile).

The IBM manual for the compiler is located at IBM XL C/C++ for AIX, V13.1, but damn if I can find the option.

What is the IBM XL C/C++ equivalent to #pragma GCC optimize? How do we instrument the source code to tell XL C/C++ to use -O2 instead of -O3?

1

There are 1 answers

10
Nicole Trudeau On BEST ANSWER

An IBM XL C/C++ for AIX V13.1 option that you could use to compile that one source file at -O2 is #pragma options optimize=2. Info about it can be found online here or in the PDF here. If you want to override -O3 that has already been specified on the command line, and control it at a function level, you may use #pragma option_override(<your function name>, "opt(level, 2)"). Info about it can be found online here or in the PDF here. You can also achieve the same thing by modifying your Makefile so that one source file gets compiled at -O2 instead of -O3.

Also, are you sure the error message you reported starting with tea.cpp:27:26 came from IBM XL C/C++ for AIX V13.1? It doesn't look like it's in the format of that product's diagnostic messages.

We will continue to monitor for your comments on Stack Overflow (tagging with xlc helps us find it), but you may find you can get a faster response time if you post your questions on our forum at http://ibm.biz/xl-power-compilers-forum, which the IBM compiler development team monitors more actively.