Closed requested to merge wip/andreask/32bit_cmp_fix into master
We used to do 64bit comparisons like this:
ChildCode64 code1 r1_lo <- iselExpr64 e1 ChildCode64 code2 r2_lo <- iselExpr64 e2 let r1_hi = getHiVRegFromLo r1_lo r2_hi = getHiVRegFromLo r2_lo cond = machOpToCond mop Just cond' = maybeFlipCond cond --TODO: Update CFG for x86 let code = code1 `appOL` code2 `appOL` toOL [ CMP II32 (OpReg r2_hi) (OpReg r1_hi), JXX cond true, JXX cond' false, CMP II32 (OpReg r2_lo) (OpReg r1_lo), JXX cond true] `appOL` genBranch false return code
This is subtly wrong.
If we have
>= as comparison and the high bits are equal we immediately jump to true.
But in fact the low bits might still go either way! We actually have to look at them to
make a final decision but we (currently) don't.
This patch fixes the logic and also rewrites it to make do with a single conditional jump.