Merge pull request #770 from OFFTKP/jump

Get rid of unnecessary jump
This commit is contained in:
psucien 2024-09-06 22:56:44 +02:00 committed by GitHub
commit f1fd846762
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -315,14 +315,12 @@ static void GenerateBLSI(const ZydisDecodedOperand* operands, Xbyak::CodeGenerat
SaveRegisters(c, {scratch}); SaveRegisters(c, {scratch});
// BLSI sets CF to zero if source is zero, otherwise it sets CF to one. // BLSI sets CF to zero if source is zero, otherwise it sets CF to one.
Xbyak::Label set_carry, clear_carry, end; Xbyak::Label clear_carry, end;
c.mov(scratch, *src); c.mov(scratch, *src);
c.neg(scratch); // NEG, like BLSI, clears CF if the source is zero and sets it otherwise c.neg(scratch); // NEG, like BLSI, clears CF if the source is zero and sets it otherwise
c.jc(set_carry); c.jnc(clear_carry);
c.jmp(clear_carry);
c.L(set_carry);
c.and_(scratch, *src); c.and_(scratch, *src);
c.stc(); // setting/clearing carry needs to happen after the AND because that clears CF c.stc(); // setting/clearing carry needs to happen after the AND because that clears CF
c.jmp(end); c.jmp(end);
@ -345,15 +343,13 @@ static void GenerateBLSMSK(const ZydisDecodedOperand* operands, Xbyak::CodeGener
SaveRegisters(c, {scratch}); SaveRegisters(c, {scratch});
Xbyak::Label set_carry, clear_carry, end; Xbyak::Label clear_carry, end;
// BLSMSK sets CF to zero if source is NOT zero, otherwise it sets CF to one. // BLSMSK sets CF to zero if source is NOT zero, otherwise it sets CF to one.
c.mov(scratch, *src); c.mov(scratch, *src);
c.test(scratch, scratch); c.test(scratch, scratch);
c.jz(set_carry); c.jnz(clear_carry);
c.jmp(clear_carry);
c.L(set_carry);
c.dec(scratch); c.dec(scratch);
c.xor_(scratch, *src); c.xor_(scratch, *src);
c.stc(); c.stc();
@ -378,15 +374,13 @@ static void GenerateBLSR(const ZydisDecodedOperand* operands, Xbyak::CodeGenerat
SaveRegisters(c, {scratch}); SaveRegisters(c, {scratch});
Xbyak::Label set_carry, clear_carry, end; Xbyak::Label clear_carry, end;
// BLSR sets CF to zero if source is NOT zero, otherwise it sets CF to one. // BLSR sets CF to zero if source is NOT zero, otherwise it sets CF to one.
c.mov(scratch, *src); c.mov(scratch, *src);
c.test(scratch, scratch); c.test(scratch, scratch);
c.jz(set_carry); c.jnz(clear_carry);
c.jmp(clear_carry);
c.L(set_carry);
c.dec(scratch); c.dec(scratch);
c.and_(scratch, *src); c.and_(scratch, *src);
c.stc(); c.stc();