- fix misc integer opcodes and remove mov statements when they have no effect

This commit is contained in:
Magnus Norddahl 2018-09-11 23:31:32 +02:00
parent 5fab45d275
commit 981950fef0

View file

@ -1448,12 +1448,14 @@ private:
void EmitSLL_RR() void EmitSLL_RR()
{ {
auto rc = CheckRegD(C, A); auto rc = CheckRegD(C, A);
if (A != B)
cc.mov(regD[A], regD[B]); cc.mov(regD[A], regD[B]);
cc.shl(regD[A], rc); cc.shl(regD[A], rc);
} }
void EmitSLL_RI() void EmitSLL_RI()
{ {
if (A != B)
cc.mov(regD[A], regD[B]); cc.mov(regD[A], regD[B]);
cc.shl(regD[A], C); cc.shl(regD[A], C);
} }
@ -1468,12 +1470,14 @@ private:
void EmitSRL_RR() void EmitSRL_RR()
{ {
auto rc = CheckRegD(C, A); auto rc = CheckRegD(C, A);
if (A != B)
cc.mov(regD[A], regD[B]); cc.mov(regD[A], regD[B]);
cc.shr(regD[A], rc); cc.shr(regD[A], rc);
} }
void EmitSRL_RI() void EmitSRL_RI()
{ {
if (A != B)
cc.mov(regD[A], regD[B]); cc.mov(regD[A], regD[B]);
cc.shr(regD[A], C); cc.shr(regD[A], C);
} }
@ -1488,12 +1492,14 @@ private:
void EmitSRA_RR() void EmitSRA_RR()
{ {
auto rc = CheckRegD(C, A); auto rc = CheckRegD(C, A);
if (A != B)
cc.mov(regD[A], regD[B]); cc.mov(regD[A], regD[B]);
cc.sar(regD[A], rc); cc.sar(regD[A], rc);
} }
void EmitSRA_RI() void EmitSRA_RI()
{ {
if (A != B)
cc.mov(regD[A], regD[B]); cc.mov(regD[A], regD[B]);
cc.sar(regD[A], C); cc.sar(regD[A], C);
} }
@ -1508,32 +1514,37 @@ private:
void EmitADD_RR() void EmitADD_RR()
{ {
auto rc = CheckRegD(C, A); auto rc = CheckRegD(C, A);
cc.mov(regD[A], konstd[B]); if (A != B)
cc.mov(regD[A], regD[B]);
cc.add(regD[A], rc); cc.add(regD[A], rc);
} }
void EmitADD_RK() void EmitADD_RK()
{ {
cc.mov(regD[A], konstd[B]); if (A != B)
cc.mov(regD[A], regD[B]);
cc.add(regD[A], konstd[C]); cc.add(regD[A], konstd[C]);
} }
void EmitADDI() void EmitADDI()
{ {
cc.mov(regD[A], konstd[B]); if (A != B)
cc.mov(regD[A], regD[B]);
cc.add(regD[A], Cs); cc.add(regD[A], Cs);
} }
void EmitSUB_RR() void EmitSUB_RR()
{ {
auto rc = CheckRegD(C, A); auto rc = CheckRegD(C, A);
if (A != B)
cc.mov(regD[A], regD[B]); cc.mov(regD[A], regD[B]);
cc.sub(regD[A], rc); cc.sub(regD[A], rc);
} }
void EmitSUB_RK() void EmitSUB_RK()
{ {
cc.mov(regD[A], konstd[B]); if (A != B)
cc.mov(regD[A], regD[B]);
cc.sub(regD[A], konstd[C]); cc.sub(regD[A], konstd[C]);
} }
@ -1547,12 +1558,14 @@ private:
void EmitMUL_RR() void EmitMUL_RR()
{ {
auto rc = CheckRegD(C, A); auto rc = CheckRegD(C, A);
if (A != B)
cc.mov(regD[A], regD[B]); cc.mov(regD[A], regD[B]);
cc.imul(regD[A], rc); cc.imul(regD[A], rc);
} }
void EmitMUL_RK() void EmitMUL_RK()
{ {
if (A != B)
cc.mov(regD[A], regD[B]); cc.mov(regD[A], regD[B]);
cc.imul(regD[A], konstd[C]); cc.imul(regD[A], konstd[C]);
} }
@ -1768,12 +1781,14 @@ private:
void EmitAND_RR() void EmitAND_RR()
{ {
auto rc = CheckRegD(C, A); auto rc = CheckRegD(C, A);
if (A != B)
cc.mov(regD[A], regD[B]); cc.mov(regD[A], regD[B]);
cc.and_(regD[A], rc); cc.and_(regD[A], rc);
} }
void EmitAND_RK() void EmitAND_RK()
{ {
if (A != B)
cc.mov(regD[A], regD[B]); cc.mov(regD[A], regD[B]);
cc.and_(regD[A], konstd[C]); cc.and_(regD[A], konstd[C]);
} }
@ -1781,12 +1796,14 @@ private:
void EmitOR_RR() void EmitOR_RR()
{ {
auto rc = CheckRegD(C, A); auto rc = CheckRegD(C, A);
if (A != B)
cc.mov(regD[A], regD[B]); cc.mov(regD[A], regD[B]);
cc.or_(regD[A], rc); cc.or_(regD[A], rc);
} }
void EmitOR_RK() void EmitOR_RK()
{ {
if (A != B)
cc.mov(regD[A], regD[B]); cc.mov(regD[A], regD[B]);
cc.or_(regD[A], konstd[C]); cc.or_(regD[A], konstd[C]);
} }
@ -1794,12 +1811,14 @@ private:
void EmitXOR_RR() void EmitXOR_RR()
{ {
auto rc = CheckRegD(C, A); auto rc = CheckRegD(C, A);
if (A != B)
cc.mov(regD[A], regD[B]); cc.mov(regD[A], regD[B]);
cc.xor_(regD[A], rc); cc.xor_(regD[A], rc);
} }
void EmitXOR_RK() void EmitXOR_RK()
{ {
if (A != B)
cc.mov(regD[A], regD[B]); cc.mov(regD[A], regD[B]);
cc.xor_(regD[A], konstd[C]); cc.xor_(regD[A], konstd[C]);
} }
@ -1868,6 +1887,7 @@ private:
void EmitNOT() void EmitNOT()
{ {
if (A != B)
cc.mov(regD[A], regD[B]); cc.mov(regD[A], regD[B]);
cc.not_(regD[A]); cc.not_(regD[A]);
} }
@ -2011,6 +2031,7 @@ private:
void EmitADDF_RR() void EmitADDF_RR()
{ {
auto rc = CheckRegF(C, A); auto rc = CheckRegF(C, A);
if (A != B)
cc.movsd(regF[A], regF[B]); cc.movsd(regF[A], regF[B]);
cc.addsd(regF[A], rc); cc.addsd(regF[A], rc);
} }
@ -2018,6 +2039,7 @@ private:
void EmitADDF_RK() void EmitADDF_RK()
{ {
auto tmp = cc.newIntPtr(); auto tmp = cc.newIntPtr();
if (A != B)
cc.movsd(regF[A], regF[B]); cc.movsd(regF[A], regF[B]);
cc.mov(tmp, ToMemAddress(&konstf[C])); cc.mov(tmp, ToMemAddress(&konstf[C]));
cc.addsd(regF[A], asmjit::x86::qword_ptr(tmp)); cc.addsd(regF[A], asmjit::x86::qword_ptr(tmp));
@ -2026,6 +2048,7 @@ private:
void EmitSUBF_RR() void EmitSUBF_RR()
{ {
auto rc = CheckRegF(C, A); auto rc = CheckRegF(C, A);
if (A != B)
cc.movsd(regF[A], regF[B]); cc.movsd(regF[A], regF[B]);
cc.subsd(regF[A], rc); cc.subsd(regF[A], rc);
} }
@ -2033,6 +2056,7 @@ private:
void EmitSUBF_RK() void EmitSUBF_RK()
{ {
auto tmp = cc.newIntPtr(); auto tmp = cc.newIntPtr();
if (A != B)
cc.movsd(regF[A], regF[B]); cc.movsd(regF[A], regF[B]);
cc.mov(tmp, ToMemAddress(&konstf[C])); cc.mov(tmp, ToMemAddress(&konstf[C]));
cc.subsd(regF[A], asmjit::x86::qword_ptr(tmp)); cc.subsd(regF[A], asmjit::x86::qword_ptr(tmp));
@ -2050,6 +2074,7 @@ private:
void EmitMULF_RR() void EmitMULF_RR()
{ {
auto rc = CheckRegF(C, A); auto rc = CheckRegF(C, A);
if (A != B)
cc.movsd(regF[A], regF[B]); cc.movsd(regF[A], regF[B]);
cc.mulsd(regF[A], rc); cc.mulsd(regF[A], rc);
} }
@ -2057,6 +2082,7 @@ private:
void EmitMULF_RK() void EmitMULF_RK()
{ {
auto tmp = cc.newIntPtr(); auto tmp = cc.newIntPtr();
if (A != B)
cc.movsd(regF[A], regF[B]); cc.movsd(regF[A], regF[B]);
cc.mov(tmp, ToMemAddress(&konstf[C])); cc.mov(tmp, ToMemAddress(&konstf[C]));
cc.mulsd(regF[A], asmjit::x86::qword_ptr(tmp)); cc.mulsd(regF[A], asmjit::x86::qword_ptr(tmp));
@ -2205,6 +2231,7 @@ private:
void EmitMINF_RR() void EmitMINF_RR()
{ {
auto rc = CheckRegF(C, A); auto rc = CheckRegF(C, A);
if (A != B)
cc.movsd(regF[A], regF[B]); cc.movsd(regF[A], regF[B]);
cc.minsd(regF[A], rc); cc.minsd(regF[A], rc);
} }
@ -2221,6 +2248,7 @@ private:
void EmitMAXF_RR() void EmitMAXF_RR()
{ {
auto rc = CheckRegF(C, A); auto rc = CheckRegF(C, A);
if (A != B)
cc.movsd(regF[A], regF[B]); cc.movsd(regF[A], regF[B]);
cc.maxsd(regF[A], rc); cc.maxsd(regF[A], rc);
} }
@ -2256,6 +2284,7 @@ private:
auto mask = cc.newDoubleConst(asmjit::kConstScopeLocal, -0.0); auto mask = cc.newDoubleConst(asmjit::kConstScopeLocal, -0.0);
auto maskXmm = cc.newXmmSd(); auto maskXmm = cc.newXmmSd();
cc.movsd(maskXmm, mask); cc.movsd(maskXmm, mask);
if (A != B)
cc.movsd(regF[A], regF[B]); cc.movsd(regF[A], regF[B]);
cc.xorpd(regF[A], maskXmm); cc.xorpd(regF[A], maskXmm);
} }