From b4c05977c28c38d2f81b48d0cb15559dc3d05564 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 24 Feb 2010 16:36:18 -0800 Subject: Optimize more easy multiplications by constants. Rather than make these changes in the libraries (*10 being a common case), let's do them once and for all in the JIT. The 2^n-1 case could be better if we generated RSB instructions, but the current "fake" RSB is still better than a full multiply. Thumb doesn't support reg/reg/reg/shift instructions, so we can't optimize the "population count <= 2" cases (such as *10) there. Tested on sholes, passion, and passion-running-sapphire (and visually inspected to check we weren't trying to generate Thumb2 instructions there). Also tested with the self-verifier. --- vm/compiler/codegen/arm/Thumb2/Gen.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'vm/compiler/codegen/arm/Thumb2/Gen.c') diff --git a/vm/compiler/codegen/arm/Thumb2/Gen.c b/vm/compiler/codegen/arm/Thumb2/Gen.c index 1390d64c7..dbce45284 100644 --- a/vm/compiler/codegen/arm/Thumb2/Gen.c +++ b/vm/compiler/codegen/arm/Thumb2/Gen.c @@ -442,3 +442,14 @@ static bool genInlinedAbsLong(CompilationUnit *cUnit, MIR *mir) storeValueWide(cUnit, rlDest, rlResult); return false; } + +static void genMultiplyByTwoBitMultiplier(CompilationUnit *cUnit, + RegLocation rlSrc, RegLocation rlResult, int lit, + int firstBit, int secondBit) +{ + opRegRegRegShift(cUnit, kOpAdd, rlResult.lowReg, rlSrc.lowReg, rlSrc.lowReg, + encodeShift(kArmLsl, secondBit - firstBit)); + if (firstBit != 0) { + opRegRegImm(cUnit, kOpLsl, rlResult.lowReg, rlResult.lowReg, firstBit); + } +} -- cgit v1.2.3