Commit 44859302 authored by ulan@chromium.org's avatar ulan@chromium.org

ARM: Try to avoid VMSR instruction and drop redundant VCVT

We were doing a redundant VCVT operation in MacroAssembler::EmitECMATruncate.
Also, setting the FPSCR exception flags is expensive on some CPUs, wo we should
try to avoid it if we can.

Thanks to Rodolph Perfetta for the input on this!

Review URL: https://chromiumcodereview.appspot.com/12217014
Patch from Hans Wennborg <hans@chromium.org>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13601 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e6c381cc
......@@ -776,15 +776,6 @@ void MacroAssembler::Strd(Register src1, Register src2,
}
void MacroAssembler::ClearFPSCRBits(const uint32_t bits_to_clear,
const Register scratch,
const Condition cond) {
vmrs(scratch, cond);
bic(scratch, scratch, Operand(bits_to_clear), LeaveCC, cond);
vmsr(scratch, cond);
}
void MacroAssembler::VFPCompareAndSetFlags(const DwVfpRegister src1,
const DwVfpRegister src2,
const Condition cond) {
......@@ -2695,15 +2686,29 @@ void MacroAssembler::EmitECMATruncate(Register result,
Label done;
// Test for values that can be exactly represented as a signed 32-bit integer.
TryFastDoubleToInt32(result, double_input, double_scratch, &done);
// Test if the value can be exactly represented as a signed integer.
vcvt_s32_f64(double_scratch.low(), double_input);
vmov(result, double_scratch.low());
vcvt_f64_s32(double_scratch, double_scratch.low());
// Note: this comparison is cheaper than reading the FPSCR exception bits.
VFPCompareAndSetFlags(double_input, double_scratch);
b(eq, &done);
// Check the exception flags. If they are not set, we are done.
// If they are set, it could be because of the conversion above, or because
// they were set before this code.
vmrs(scratch);
tst(scratch, Operand(kVFPOverflowExceptionBit |
kVFPUnderflowExceptionBit |
kVFPInvalidOpExceptionBit));
b(eq, &done);
// Clear cumulative exception flags.
ClearFPSCRBits(kVFPExceptionMask, scratch);
bic(scratch, scratch, Operand(kVFPExceptionMask));
vmsr(scratch);
// Try a conversion to a signed integer.
vcvt_s32_f64(double_scratch.low(), double_input);
vmov(result, double_scratch.low());
// Retrieve he FPSCR.
// Retrieve the FPSCR.
vmrs(scratch);
// Check for overflow and NaNs.
tst(scratch, Operand(kVFPOverflowExceptionBit |
......
......@@ -460,11 +460,6 @@ class MacroAssembler: public Assembler {
const MemOperand& dst,
Condition cond = al);
// Clear specified FPSCR bits.
void ClearFPSCRBits(const uint32_t bits_to_clear,
const Register scratch,
const Condition cond = al);
// Compare double values and move the result to the normal condition flags.
void VFPCompareAndSetFlags(const DwVfpRegister src1,
const DwVfpRegister src2,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment