I'm wondering what the difference between those two intrinsics is, and if there is a significant difference between them when dealing with a interrupt vector like TAIV on the MSP430.
My understanding is, that:
switch (__even_in_range( x , NUM ))
{
...
}
Will tell the compiler that x is an even number and takes on values from 0 to NUM (inclusive). The compiler can therefore generate an optimized jumptable based on that assumption (which it isn't allowed to do otherwise).
Now if I'd write:
switch (x)
{
...
default: _never_executed()
}
with the same x and the same cases (so it's still even and in range of 0 to NUM), would this create a code which is equally optimized or is there a difference between them?
My understanding of _never_executed() is that it tells the compiler that the x can only take the values of the cases given, and then can optimize the code based on that knowledge. But there is no restriction on x being even.
Maybe for personal reasons I like the _never_executed() intrinsic more (it's less intimidating) than the __even_in_range() intrinsic, and they work in a similar manner, they both are able to optimize the switch statement using knowledge about the range of the statement. But if the __even_in_range() generates better (faster, more efficient) code then I should probably use it rather than _never_executed().