From 4dff2fdca6dc0032032ff324161c6343e675e4b0 Mon Sep 17 00:00:00 2001 From: Alexandre Rames Date: Thu, 20 Aug 2015 13:36:35 +0100 Subject: [PATCH] ARM64: Minor optimization for conversions from long to int. Change-Id: Ice7febba8dd09a4548ab235fc8aee76d7e7676a1 --- compiler/optimizing/code_generator_arm64.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc index 41523557c..25b3ea2f5 100644 --- a/compiler/optimizing/code_generator_arm64.cc +++ b/compiler/optimizing/code_generator_arm64.cc @@ -3202,6 +3202,15 @@ void InstructionCodeGeneratorARM64::VisitTypeConversion(HTypeConversion* convers Register source = InputRegisterAt(conversion, 0); if ((result_type == Primitive::kPrimChar) && (input_size < result_size)) { __ Ubfx(output, source, 0, result_size * kBitsPerByte); + } else if (result_type == Primitive::kPrimInt && input_type == Primitive::kPrimLong) { + // 'int' values are used directly as W registers, discarding the top + // bits, so we don't need to sign-extend and can just perform a move. + // We do not pass the `kDiscardForSameWReg` argument to force clearing the + // top 32 bits of the target register. We theoretically could leave those + // bits unchanged, but we would have to make sure that no code uses a + // 32bit input value as a 64bit value assuming that the top 32 bits are + // zero. + __ Mov(output.W(), source.W()); } else if ((result_type == Primitive::kPrimChar) || ((input_type == Primitive::kPrimChar) && (result_size > input_size))) { __ Ubfx(output, output.IsX() ? source.X() : source.W(), 0, min_size * kBitsPerByte); -- 2.11.0