|
|
|
|
|
by hinkley
466 days ago
|
|
> The intent is to
produce the mask values without using a plain comparison (“x != 0”) so that the compiler
does not notice that we are really making a conditional move.
The compiler is not fooled. So practice your martial arts on the bow of a rowboat. Balance, Danielsan. The whole timing thing is essentially an issue of getting off-balance as in martial arts and the solution is that there are actions you simply never do, and ones that look like they lack economy of motion because so much of the work is in keeping your center of gravity from shifting outside of your base. Tai chi is infinitely better at protecting you from concussing yourself on black ice than it is at protecting you from a mugger. So if you have a conditional move for one calculation, then move a to b if !c and move it to d if c. And when the compilers chase that down in another generation, or someone notices that the L1 cache timing is different if d gets cold, then use both calculations in the output. Calculate complements where the runtime of a + !a = 1 to several decimal points. Will it work for eternity? Unlikely. Will it work for a decade? Probably. |
|