4 ms·
Where do you ever need 1 instead of -1? If you are using it to increment something, -1 is just as good. Storing a bool value in memory is rarely done, vs. using
by ncmncm 7y ago
Where do you ever need 1 instead of -1? If you are using it to increment something, -1 is just as good. Storing a bool value in memory is rarely done, vs. using and discarding it. But in use, having a value to AND with, without need to dink around first, makes a big difference, particularly when cmov instructions are lacking.
If the cost of negating before storing got to seem excessive, a single negate-and-store-word instruction could translate, but it would be used a very great deal less than negating the 1 to make a mask.
However simple it looks to decode the thicket of compare-and-branch instructions, decoding and executing exactly one conditional branch instruction that just checks for zero will be simpler and faster.
You still have the SET family to decode, but you need them anyway.