emit_x64_data_processing: Reduce codesize of LogicalShiftRight32 for carry case
This commit is contained in:
parent
58ff457339
commit
a2a687f208
1 changed files with 9 additions and 29 deletions
|
@ -492,38 +492,18 @@ void EmitX64::EmitLogicalShiftRight32(EmitContext& ctx, IR::Inst* inst) {
|
|||
ctx.EraseInstruction(carry_inst);
|
||||
ctx.reg_alloc.DefineValue(inst, result);
|
||||
} else {
|
||||
ctx.reg_alloc.Use(shift_arg, HostLoc::RCX);
|
||||
const Xbyak::Reg32 result = ctx.reg_alloc.UseScratchGpr(operand_arg).cvt32();
|
||||
ctx.reg_alloc.UseScratch(shift_arg, HostLoc::RCX);
|
||||
const Xbyak::Reg32 operand = ctx.reg_alloc.UseGpr(operand_arg).cvt32();
|
||||
const Xbyak::Reg32 result = ctx.reg_alloc.ScratchGpr().cvt32();
|
||||
const Xbyak::Reg32 carry = ctx.reg_alloc.UseScratchGpr(carry_arg).cvt32();
|
||||
|
||||
// TODO: Optimize this.
|
||||
|
||||
code.inLocalLabel();
|
||||
|
||||
code.cmp(code.cl, 32);
|
||||
code.ja(".Rs_gt32");
|
||||
code.je(".Rs_eq32");
|
||||
// if (Rs & 0xFF == 0) goto end;
|
||||
code.test(code.cl, code.cl);
|
||||
code.jz(".end");
|
||||
// if (Rs & 0xFF < 32) {
|
||||
code.shr(result, code.cl);
|
||||
code.mov(result, 63);
|
||||
code.cmp(code.cl, 63);
|
||||
code.cmovnb(code.ecx, result);
|
||||
code.mov(result, operand);
|
||||
code.bt(carry.cvt32(), 0);
|
||||
code.shr(result.cvt64(), code.cl);
|
||||
code.setc(carry.cvt8());
|
||||
code.jmp(".end");
|
||||
// } else if (Rs & 0xFF > 32) {
|
||||
code.L(".Rs_gt32");
|
||||
code.xor_(result, result);
|
||||
code.xor_(carry, carry);
|
||||
code.jmp(".end");
|
||||
// } else if (Rs & 0xFF == 32) {
|
||||
code.L(".Rs_eq32");
|
||||
code.bt(result, 31);
|
||||
code.setc(carry.cvt8());
|
||||
code.xor_(result, result);
|
||||
// }
|
||||
code.L(".end");
|
||||
|
||||
code.outLocalLabel();
|
||||
|
||||
ctx.reg_alloc.DefineValue(carry_inst, carry);
|
||||
ctx.EraseInstruction(carry_inst);
|
||||
|
|
Loading…
Reference in a new issue