Fix constant folding for cmov and add folding of or/and/xor (457456, r=danderson).

This commit is contained in:
Andreas Gal 2008-09-27 13:10:24 -07:00
Родитель 2f56600a43
Коммит 544b9ea897
1 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -691,6 +691,10 @@ namespace nanojit
// c ? a : a => a
return oprnd2->oprnd1();
}
if (oprnd1->isconst()) {
// const ? x : y => return x or y depending on const
return oprnd1->constval() ? oprnd2->oprnd1() : oprnd2->oprnd2();
}
}
if (oprnd1 == oprnd2)
{
@ -740,6 +744,12 @@ namespace nanojit
return insImm(int32_t(c1) << int32_t(c2));
if (v == LIR_ush)
return insImm(uint32_t(c1) >> int32_t(c2));
if (v == LIR_or)
return insImm(uint32_t(c1) | int32_t(c2));
if (v == LIR_and)
return insImm(uint32_t(c1) & int32_t(c2));
if (v == LIR_xor)
return insImm(uint32_t(c1) ^ int32_t(c2));
}
else if (oprnd1->isconstq() && oprnd2->isconstq())
{
@ -774,10 +784,6 @@ namespace nanojit
oprnd1 = t;
v = LOpcode(v^1);
}
else if (v == LIR_cmov || v == LIR_qcmov) {
// const ? x : y => return x or y depending on const
return oprnd1->constval() ? oprnd2->oprnd1() : oprnd2->oprnd2();
}
}
if (oprnd2->isconst())