Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

/qansi-alias or /oa?

BSK
Beginner
459 Views
Hello,

Which switch should allow the most optimizations? /qansi-alias or /oa?

Thank you.
0 Kudos
4 Replies
TimP
Honored Contributor III
459 Views
Quoting - BSK

Which switch should allow the most optimizations? /qansi-alias or /oa?

/Qansi-alias asserts that your program conforms with standard (does not alias between incompatible data types). It's equivalent to default options of most compilers, such as gcc -fstrict-aliasing. /Oa effectively asserts a restrict qualifier on all arguments, so would enable more optimization (like Fortran) in the case where you have multiple parameter pointers to compatible type, and didn't set restrict qualifiers. /Oa could break programs which conform with C standard, but should be OK for C functions called by Fortran standard conforming programs. A possible alternative which operates at loop level is #pragma ivdep

0 Kudos
BSK
Beginner
459 Views
Quoting - tim18
/Qansi-alias asserts that your program conforms with standard (does not alias between incompatible data types). It's equivalent to default options of most compilers, such as gcc -fstrict-aliasing. /Oa effectively asserts a restrict qualifier on all arguments, so would enable more optimization (like Fortran) in the case where you have multiple parameter pointers to compatible type, and didn't set restrict qualifiers. /Oa could break programs which conform with C standard, but should be OK for C functions called by Fortran standard conforming programs. A possible alternative which operates at loop level is #pragma ivdep

Thank you tim18, it's more or less what I thought. If I understand correclty /Qansi-alias asserts my program may have aliasings (allowed by the standard), while /Oa asserts my program does not have aliasing at all.

Then, shouldn't /Oa allow more optimizations than /Qansi-alias? I compiled some C and C++ programs, and they are faster with /Qansi-alias.
0 Kudos
TimP
Honored Contributor III
459 Views
Quoting - BSK
Thank you tim18, it's more or less what I thought. If I understand correclty /Qansi-alias asserts my program may have aliasings (allowed by the standard), while /Oa asserts my program does not have aliasing at all.

Then, shouldn't /Oa allow more optimizations than /Qansi-alias? I compiled some C and C++ programs, and they are faster with /Qansi-alias.
It's good to hear that /Qansi-alias is effective for your application. /Oa is somewhat of a dilemma, as it's there to support optimizations which are possible with Microsoft compilers (or at least to accept the command line), but it may have to be cautious about the extent to which it goes beyond MSVC, or is combined with optimizations which MSVC doesn't perform, risky or not.
Perhaps I should have been more explicit; it may be preferable to write restrict qualifiers into your source code rather than try to compensate for their absence by using /Oa. That's somewhat of a dilemma too, as MSVC doesn't appear to implement their documented version of restrict, and Intel compilers may implement the Microsoft spelling of it only for linux (!?). Anyway, it's preferable to be specific about the optimizations you are looking for, rather than attempt them with an option like /Oa which explicitly conflicts with standards. No doubt I'm getting too opinionated.
0 Kudos
BSK
Beginner
459 Views
Quoting - tim18
It's good to hear that /Qansi-alias is effective for your application. /Oa is somewhat of a dilemma, as it's there to support optimizations which are possible with Microsoft compilers (or at least to accept the command line), but it may have to be cautious about the extent to which it goes beyond MSVC, or is combined with optimizations which MSVC doesn't perform, risky or not.
Perhaps I should have been more explicit; it may be preferable to write restrict qualifiers into your source code rather than try to compensate for their absence by using /Oa. That's somewhat of a dilemma too, as MSVC doesn't appear to implement their documented version of restrict, and Intel compilers may implement the Microsoft spelling of it only for linux (!?). Anyway, it's preferable to be specific about the optimizations you are looking for, rather than attempt them with an option like /Oa which explicitly conflicts with standards. No doubt I'm getting too opinionated.
Oh I didn't know MSVC had /Oa (and /Ow). It makes sense now, icl has these switches for compatibility.
I'm satisfied by the performance of my build, it's just I was a confused about /Oa and /Qansi-alias because the descriptions were a bit unclear for me.

Thanks again tim18.
0 Kudos
Reply