Simplify branching in float compare vops
The float compare vop for >
does something like:
jmp :p <not-lab>
jmp :a <target>
We remove the extra jmps by noticing that for jmp :a
to happen, the
carry flag must be 0 (and zero flag is 0). If NaN occurred, the
parity bit is set and so is the carry. So we only jump to the target
when the carry bit is 0 and the parity bit is not, which is exactly
what we want.
For the not-p case,
jmp :np <target>
jmp :na <target>
For the not-p case for >
, we're trying to branch to target is x <= y
. This is equivalent to branching if y >= x
, which means jmp :ae
. That means the carry flag is 0. But this can only happen if
the parity bit is also zero.