I normally code in Java, but I've recently looked at ways C code is optimized manually. One thing that is often done (beyond loop hoisting) is eliminate "conditionals" using "math". This usually relies on "boolean" values (result of "a == b" for example) also being an integer type, that can be used to multiply other values. But in Java, boolean is not an integer. I could convert a boolean "flag" into an integer like this:
int i = flag ? 1 : 0;
But "syntactically", this is also a "conditional". My question is, is this normally turned into something "jump-free" by the JIT?
If not, but some other expression would result in the desired effect, I'd like to know that too.
EDIT: Based on the comments, I'll be more specific: is the expression optimized in the Oracle JVM, for x86/x64 (Intel/AMD) CPUs.