Register result = ToRegister(instr->result());
int32_t divisor = instr->divisor();
+ // If the divisor is 1, return the dividend.
+ if (divisor == 1) {
+ __ Move(result, dividend);
+ return;
+ }
+
// If the divisor is positive, things are easy: There can be no deopts and we
// can simply do an arithmetic right shift.
- if (divisor == 1) return;
int32_t shift = WhichPowerOf2Abs(divisor);
if (divisor > 1) {
__ mov(result, Operand(dividend, ASR, shift));
Register result = ToRegister32(instr->result());
int32_t divisor = instr->divisor();
+ // If the divisor is 1, return the dividend.
+ if (divisor == 1) {
+ __ Mov(result, dividend, kDiscardForSameWReg);
+ return;
+ }
+
// If the divisor is positive, things are easy: There can be no deopts and we
// can simply do an arithmetic right shift.
- if (divisor == 1) return;
int32_t shift = WhichPowerOf2Abs(divisor);
if (divisor > 1) {
__ Mov(result, Operand(dividend, ASR, shift));
return;
}
- // Using a conditional data processing instruction would need 1 more register.
- Label not_kmin_int, done;
- __ B(vc, ¬_kmin_int);
- __ Mov(result, kMinInt / divisor);
- __ B(&done);
- __ bind(¬_kmin_int);
- __ Mov(result, Operand(dividend, ASR, shift));
- __ bind(&done);
+ __ Asr(result, dividend, shift);
+ __ Csel(result, result, kMinInt / divisor, vc);
}