SHLD/SHRD: Less broken flags, correct zero shifts

This commit is contained in:
Stefanos Kornilios Mitsis Poiitidis committed 2020-09-15 13:42:43 +03:00
1 parent ceb316d97e
commit d441ebe489
1 file changed
+7 -4
@@ -1598,16 +1598,18 @@ void OpDispatchBuilder::SHLDOp(OpcodeArgs) {
else
Shift = _And(Shift, _Constant(0x1F));
auto ShiftRight = _Sub(_Constant(Size), Shift);
auto ShiftRight = _Sub(_Constant(Size-1), Shift);
OrderedNode *Res{};
auto Tmp1 = _Lshl(Dest, Shift);
auto Tmp2 = _Lshr(Src, ShiftRight);
Tmp2 = _Lshr(Tmp2, _Constant(1));
Res = _Or(Tmp1, Tmp2);
StoreResult(GPRClass, Op, Res, -1);
GenerateFlags_ShiftLeft(Op, _Bfe(Size, 0, Res), _Bfe(Size, 0, Dest), _Bfe(Size, 0, Src));
GenerateFlags_ShiftLeft(Op, _Bfe(Size, 0, Res), _Bfe(Size, 0, Dest), _Bfe(Size, 0, Shift));
}
void OpDispatchBuilder::SHLDImmediateOp(OpcodeArgs) {
@@ -1652,15 +1654,16 @@ void OpDispatchBuilder::SHRDOp(OpcodeArgs) {
else
Shift = _And(Shift, _Constant(0x1F));
auto ShiftLeft = _Sub(_Constant(Size), Shift);
auto ShiftLeft = _Sub(_Constant(Size-1), Shift);
OrderedNode *Res{};
auto Tmp1 = _Lshr(Dest, Shift);
auto Tmp2 = _Lshl(Src, ShiftLeft);
Tmp2 = _Lshl(Tmp2, _Constant(1));
Res = _Or(Tmp1, Tmp2);
StoreResult(GPRClass, Op, Res, -1);
GenerateFlags_ShiftRight(Op, _Bfe(Size, 0, Res), _Bfe(Size, 0, Dest), _Bfe(Size, 0, Src));
GenerateFlags_ShiftRight(Op, _Bfe(Size, 0, Res), _Bfe(Size, 0, Dest), _Bfe(Size, 0, Shift));
}
void OpDispatchBuilder::SHRDImmediateOp(OpcodeArgs) {