OSDN Git Service

ART: Eliminate unlikely code from hot path in x86 div/rem
authorSerguei Katkov <serguei.i.katkov@intel.com>
Fri, 15 Apr 2016 10:50:25 +0000 (16:50 +0600)
committerSerguei Katkov <serguei.i.katkov@intel.com>
Tue, 26 Apr 2016 12:21:35 +0000 (18:21 +0600)
Division and Remainder when numerator is zero is not
usual case so remove the check for this case from hot path.

Change-Id: Ie575af0fedb5045d4ed74292a61a8378f82d39ae
Signed-off-by: Serguei Katkov <serguei.i.katkov@intel.com>
compiler/optimizing/code_generator_x86.cc
compiler/optimizing/code_generator_x86_64.cc

index e73e880..748fa26 100644 (file)
@@ -3303,17 +3303,6 @@ void InstructionCodeGeneratorX86::GenerateDivRemWithAnyConstant(HBinaryOperation
   int shift;
   CalculateMagicAndShiftForDivRem(imm, false /* is_long */, &magic, &shift);
 
-  NearLabel ndiv;
-  NearLabel end;
-  // If numerator is 0, the result is 0, no computation needed.
-  __ testl(eax, eax);
-  __ j(kNotEqual, &ndiv);
-
-  __ xorl(out, out);
-  __ jmp(&end);
-
-  __ Bind(&ndiv);
-
   // Save the numerator.
   __ movl(num, eax);
 
@@ -3348,7 +3337,6 @@ void InstructionCodeGeneratorX86::GenerateDivRemWithAnyConstant(HBinaryOperation
   } else {
     __ movl(eax, edx);
   }
-  __ Bind(&end);
 }
 
 void InstructionCodeGeneratorX86::GenerateDivRemIntegral(HBinaryOperation* instruction) {
index 5576d83..9a4c67b 100644 (file)
@@ -3390,16 +3390,6 @@ void InstructionCodeGeneratorX86_64::GenerateDivRemWithAnyConstant(HBinaryOperat
 
     __ movl(numerator, eax);
 
-    NearLabel no_div;
-    NearLabel end;
-    __ testl(eax, eax);
-    __ j(kNotEqual, &no_div);
-
-    __ xorl(out, out);
-    __ jmp(&end);
-
-    __ Bind(&no_div);
-
     __ movl(eax, Immediate(magic));
     __ imull(numerator);
 
@@ -3425,7 +3415,6 @@ void InstructionCodeGeneratorX86_64::GenerateDivRemWithAnyConstant(HBinaryOperat
     } else {
       __ movl(eax, edx);
     }
-    __ Bind(&end);
   } else {
     int64_t imm = second.GetConstant()->AsLongConstant()->GetValue();