ART: Delete code optimizing a%1 and a%-1 from InstructionCodeGeneratorARM64
In InstructionWithAbsorbingInputSimplifier there is code optimizing a%1
and a%-1. So the code in InstructionCodeGeneratorARM64 optimizing such
cases can be deleted.
This patch deletes the code from InstructionCodeGeneratorARM64 and adds
additional tests.
Test: 012-math, 014-math3, 411-optimizing-arith, 411-checker-hdiv-hrem-pow2
Test: 701-easy-div-rem, 442-checker-constant-folding
Test: test-art-host, test-art-target
Change-Id: Ib80c0aa4c3e28b07fa79bb43783274c9d7fc456a
diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc
index d1c83ce..02c995a 100644
--- a/compiler/optimizing/code_generator_arm64.cc
+++ b/compiler/optimizing/code_generator_arm64.cc
@@ -5678,14 +5678,6 @@
}
}
-void InstructionCodeGeneratorARM64::GenerateIntRemForOneOrMinusOneDenom(HRem *instruction) {
- int64_t imm = Int64FromLocation(instruction->GetLocations()->InAt(1));
- DCHECK(imm == 1 || imm == -1) << imm;
-
- Register out = OutputRegister(instruction);
- __ Mov(out, 0);
-}
-
void InstructionCodeGeneratorARM64::GenerateIntRemForConstDenom(HRem *instruction) {
int64_t imm = Int64FromLocation(instruction->GetLocations()->InAt(1));
@@ -5695,10 +5687,12 @@
return;
}
- if (imm == 1 || imm == -1) {
- // TODO: These cases need to be optimized in InstructionSimplifier
- GenerateIntRemForOneOrMinusOneDenom(instruction);
- } else if (IsPowerOfTwo(AbsOrMin(imm))) {
+ if (IsPowerOfTwo(AbsOrMin(imm))) {
+ // Cases imm == -1 or imm == 1 are handled in constant folding by
+ // InstructionWithAbsorbingInputSimplifier.
+ // If the cases have survided till code generation they are handled in
+ // GenerateIntRemForPower2Denom becauses -1 and 1 are the power of 2 (2^0).
+ // The correct code is generated for them, just more instructions.
GenerateIntRemForPower2Denom(instruction);
} else {
DCHECK(imm < -2 || imm > 2) << imm;