3 ms·
My point was, anywhere there's a hidden 'if' can be branching. If there's no calculation being done, it'll simplify. value = (test) ? const0 : const1; Bu
by yarg 3y ago
My point was, anywhere there's a hidden 'if' can be branching.
If there's no calculation being done, it'll simplify.
value = (test) ? const0 : const1;
But if calculations are being done, it won't.
value = (test) ? calc0() : calc1();
If you want non-branching where the ternary options are calculated, you need to calculate both.
This matters most with SIMD operations.
Look at section 2.5.1 (Branch-Equivalent SIMD Processing)
http://ftp.cvut.cz/kernel/people/geoff/cell/ps3-linux-docs/CellProgrammingTutorial/BasicsOfSIMDProgramming.html http://ftp.cvut.cz/kernel/people/geoff/cell/ps3-linux-docs/C...
- juliusgeo 3y agoAh, yeah I see what you mean. If I'm understanding you correctly, the fact that we are calling the Python interpreter internal functions during that calculation makes it branch because it is not pre-calculated?
- yarg 3y agoPretty much (at least as far as I understand it). There's probably something at the instruction level which allows the constant ternary expressions to be non-branching.