Fix mochitest failures caused by the patch for
bug 498193. r=me.
--- a/js/src/nanojit/LIR.cpp
+++ b/js/src/nanojit/LIR.cpp
@@ -929,17 +929,27 @@ namespace nanojit
case LTy_Void: NanoAssert(0); break;
default: NanoAssert(0); break;
}
return insStore(op, value, base, d, accSet);
}
LIns* LirWriter::ins_choose(LIns* cond, LIns* iftrue, LIns* iffalse, bool use_cmov)
{
- NanoAssert(cond->isCmp());
+ // 'cond' must be a conditional, unless it has been optimized to 0 or
+ // 1. In that case make it an ==0 test and flip the branches. It'll
+ // get constant-folded by ExprFilter subsequently.
+ if (!cond->isCmp()) {
+ NanoAssert(cond->isconst());
+ cond = ins_eq0(cond);
+ LInsp tmp = iftrue;
+ iftrue = iffalse;
+ iffalse = tmp;
+ }
+
if (use_cmov) {
LOpcode op = LIR_cmov;
if (iftrue->isI32() && iffalse->isI32()) {
op = LIR_cmov;
#ifdef NANOJIT_64BIT
} else if (iftrue->isI64() && iffalse->isI64()) {
op = LIR_qcmov;
#endif