Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

__builtin_expect() for switch() statement

$
0
0

Greetings,

I am using hints for ICC regarding branch prediction, i.e.:

#ifndef my_likely
#   if defined(__GNUC__) || defined(__INTEL_COMPILER)
#       define my_likely(x)     __builtin_expect(!!(x),1)
#       define my_unlikely(x)   __builtin_expect(!!(x),0)
#   else
#       define my_likely(x)     (x)
#       define my_unlikely(x)   (x)
#   endif
#endif

and it is used as e.g.:

signed int x=...;
if(my_likely(x>0)) {
    ....
}

but what about "switch(...)" branching statement + "case:""labels" ? is there any way to instruct compiler that "case:" label is "likely" more than others?

This is crucial for my application to enforce branch prediction at compile time.

If Intel have no support for this, then, please, take this as a "feature support request".

Best,

VooDooMan


Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>