[Interest] How does one use Q_ASSUME?
René J.V. Bertin
rjvbertin at gmail.com
Sun May 26 16:10:07 CEST 2019
On Sunday May 26 2019 14:10:46 Elvis Stansvik wrote:
>to check if p is 1, else check if p is 2. With the default: added with
>the unreachable hint, it's enough for it to generate instructions to
>check if p is 1, because if it isn't, then it is 2 for sure (because
>the default:, which covers every other value of p, is unreachable).
Yes, that one I can see; the compiler can just construct a jump (computed go-to) table for the non-default cases and doesn't need to generate anything else.
> It is compiler specific like you say, but Q_ASSUME is not. It will
What I meant is that the effect is compiler specific, as every compiler will have its own implementation, and every compiler will generate its own series of instructions for a given bit of code. Your explanation about using vector instructions wouldn't hold for a compiler that doesn't use them, for instance.
R
More information about the Interest
mailing list