summaryrefslogtreecommitdiff
path: root/compiler/optimizing
diff options
context:
space:
mode:
author Alexandre Rames <alexandre.rames@linaro.org> 2015-10-16 09:08:46 +0100
committer Alexandre Rames <alexandre.rames@linaro.org> 2015-10-16 09:08:46 +0100
commitb69fbfb5e43e404270e63b7a35dc5645b29b759c (patch)
treeb41c69a226238e75bbb497930f86d5463dda31a5 /compiler/optimizing
parent28c34f886521f422424768fe245b98b7b83c6bd7 (diff)
ARM64: Better recognition of constants encodable as immediates.
When the right-hand side input is a constant, VIXL will automatically switch between add and sub (or between similar pairs of instructions). Change-Id: Icf05237b8653c409618f44e45049df87baf0f4c6
Diffstat (limited to 'compiler/optimizing')
-rw-r--r--compiler/optimizing/common_arm64.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/optimizing/common_arm64.h b/compiler/optimizing/common_arm64.h
index f54547534f..4abe5e953c 100644
--- a/compiler/optimizing/common_arm64.h
+++ b/compiler/optimizing/common_arm64.h
@@ -206,7 +206,9 @@ static bool CanEncodeConstantAsImmediate(HConstant* constant, HInstruction* inst
if (instr->IsAdd() || instr->IsSub() || instr->IsCondition() ||
instr->IsCompare() || instr->IsBoundsCheck()) {
// Uses aliases of ADD/SUB instructions.
- return vixl::Assembler::IsImmAddSub(value);
+ // If `value` does not fit but `-value` does, VIXL will automatically use
+ // the 'opposite' instruction.
+ return vixl::Assembler::IsImmAddSub(value) || vixl::Assembler::IsImmAddSub(-value);
} else if (instr->IsAnd() || instr->IsOr() || instr->IsXor()) {
// Uses logical operations.
return vixl::Assembler::IsImmLogical(value, vixl::kXRegSize);