Revision: 13601
Author:   [email protected]
Date:     Wed Feb  6 02:32:02 2013
Log:      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 <[email protected]>.
http://code.google.com/p/v8/source/detail?r=13601

Modified:
 /branches/bleeding_edge/src/arm/macro-assembler-arm.cc
 /branches/bleeding_edge/src/arm/macro-assembler-arm.h

=======================================
--- /branches/bleeding_edge/src/arm/macro-assembler-arm.cc Mon Feb 4 04:01:59 2013 +++ /branches/bleeding_edge/src/arm/macro-assembler-arm.cc Wed Feb 6 02:32:02 2013
@@ -774,15 +774,6 @@
     }
   }
 }
-
-
-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,
@@ -2695,15 +2686,29 @@

   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 |
=======================================
--- /branches/bleeding_edge/src/arm/macro-assembler-arm.h Mon Feb 4 04:01:59 2013 +++ /branches/bleeding_edge/src/arm/macro-assembler-arm.h Wed Feb 6 02:32:02 2013
@@ -460,11 +460,6 @@
             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,

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to