Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
7693 Discussions

How to disable "-no-prec-div" only in a few lines

maverick6664
Beginner
217 Views
Title says it all.

I know "#pragma optimize("",on/off)", but these turn on/off all optimization per function or per file. I want to control only prec-div option only in a few lines in a function. How can I do it?

"Making a non-optimized function outside" is out of the question.

TIA.
0 Kudos
2 Replies
Rhys_Ulerich
New Contributor I
217 Views
Ever get a solution to this one? Is it possible to use #pragma optimize or optimization_level in conjunction with an inline or forceinline function to achieve this?

- Rhys
TimP
Black Belt
217 Views
You could use ipo with some functions built with -prec-div and others not. More common, particularly in the last 4 years, when most CPUs have efficient dividers, is to use -prec-div always and write out explicitly where optimizations on divide are wanted:
float tmp = 1/denom;
a *= tmp;
b *= tmp;
Reply