summaryrefslogtreecommitdiffstats
path: root/compiler/dex/quick/mir_to_lir.h
diff options
context:
space:
mode:
authorNingsheng Jian <ningsheng.jian@arm.com>2014-10-23 13:48:36 +0800
committerIan Rogers <irogers@google.com>2014-11-05 11:37:37 -0800
commit675e09b2753c2fcd521bd8f0230a0abf06e9b0e9 (patch)
tree9a5f41cb1dd1930ae003feeccb4211d59b465e19 /compiler/dex/quick/mir_to_lir.h
parent211d45e059935a7874a1ec89846f03d35ffba29f (diff)
downloadart-675e09b2753c2fcd521bd8f0230a0abf06e9b0e9.tar.gz
art-675e09b2753c2fcd521bd8f0230a0abf06e9b0e9.tar.bz2
art-675e09b2753c2fcd521bd8f0230a0abf06e9b0e9.zip
ARM: Strength reduction for floating-point division
For floating-point division by power of two constants, generate multiplication by the reciprocal instead. Change-Id: I39c79eeb26b60cc754ad42045362b79498c755be
Diffstat (limited to 'compiler/dex/quick/mir_to_lir.h')
-rw-r--r--compiler/dex/quick/mir_to_lir.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/compiler/dex/quick/mir_to_lir.h b/compiler/dex/quick/mir_to_lir.h
index 4623f79466..bacc6d2e41 100644
--- a/compiler/dex/quick/mir_to_lir.h
+++ b/compiler/dex/quick/mir_to_lir.h
@@ -789,6 +789,7 @@ class Mir2Lir : public Backend {
virtual bool HandleEasyDivRem(Instruction::Code dalvik_opcode, bool is_div,
RegLocation rl_src, RegLocation rl_dest, int lit);
bool HandleEasyMultiply(RegLocation rl_src, RegLocation rl_dest, int lit);
+ bool HandleEasyFloatingPointDiv(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2);
virtual void HandleSlowPaths();
void GenBarrier();
void GenDivZeroException();
@@ -1120,6 +1121,10 @@ class Mir2Lir : public Backend {
virtual bool SmallLiteralDivRem(Instruction::Code dalvik_opcode, bool is_div,
RegLocation rl_src, RegLocation rl_dest, int lit) = 0;
virtual bool EasyMultiply(RegLocation rl_src, RegLocation rl_dest, int lit) = 0;
+ virtual void GenMultiplyByConstantFloat(RegLocation rl_dest, RegLocation rl_src1,
+ int32_t constant) = 0;
+ virtual void GenMultiplyByConstantDouble(RegLocation rl_dest, RegLocation rl_src1,
+ int64_t constant) = 0;
virtual LIR* CheckSuspendUsingLoad() = 0;
virtual RegStorage LoadHelper(QuickEntrypointEnum trampoline) = 0;
@@ -1439,6 +1444,26 @@ class Mir2Lir : public Backend {
return InexpensiveConstantInt(value);
}
+ /**
+ * @brief Whether division by the given divisor can be converted to multiply by its reciprocal.
+ * @param divisor A constant divisor bits of float type.
+ * @return Returns true iff, x/divisor == x*(1.0f/divisor), for every float x.
+ */
+ bool CanDivideByReciprocalMultiplyFloat(int32_t divisor) {
+ // True, if float value significand bits are 0.
+ return ((divisor & 0x7fffff) == 0);
+ }
+
+ /**
+ * @brief Whether division by the given divisor can be converted to multiply by its reciprocal.
+ * @param divisor A constant divisor bits of double type.
+ * @return Returns true iff, x/divisor == x*(1.0/divisor), for every double x.
+ */
+ bool CanDivideByReciprocalMultiplyDouble(int64_t divisor) {
+ // True, if double value significand bits are 0.
+ return ((divisor & ((UINT64_C(1) << 52) - 1)) == 0);
+ }
+
// May be optimized by targets.
virtual void GenMonitorEnter(int opt_flags, RegLocation rl_src);
virtual void GenMonitorExit(int opt_flags, RegLocation rl_src);