diff options
author | 2023-12-11 17:02:22 +0000 | |
---|---|---|
committer | 2023-12-13 16:42:23 +0000 | |
commit | f9562dc6e14621961dd5276c6669bf0adb84e149 (patch) | |
tree | 969f4ab8e7435871e14490f80e38ecd68bab5a6d /compiler/optimizing/instruction_simplifier.cc | |
parent | 516f36d70993d9d43c9989a77bfe279051acefe5 (diff) |
riscv64: Clean up the `SystemArrayCopy` intrinsic.
Define a new optimization flag for source and destination
position match. Use it to avoid the forward-copy check
(where the assembler optimized away a BLT instruction,
so we had just a useless BNE to the next instruction) and
one position sign check.
Avoid checking that the position is inside the array. The
subsequent subtraction cannot underflow an `int32_t` and
the following BLT shall go to the slow path for negative
values anyway.
Rewrite the array type check to avoid unnecessary checks
and read barriers.
Use an allocated temporary instead of scratch register
for the marking in the read barrier slow path. Simplify
the gray bit check and the fake dependency.
Use constant position and length locations for small
constant values. (It was probably an oversight that we
used it only for large constant values.)
Emit threshold check when the length equals source or
destination length. The old code allowed the intrinsic
to process array copy of an arbirary length.
Use `ShNAdd()` for faster array address calculations.
Use helper functions and lambdas to simplify the code.
Pass registers and locations by value. Prefer load/store
macro instructions over raw load/store instructions. Use
a bare conditional branch to assert the `TMP` shall not
be clobbered.
Test: testrunner.py --target --64 --ndebug --optimizing
Bug: 283082089
Change-Id: I3f697b4a74497d6d712a92450a6a45e772430662
Diffstat (limited to 'compiler/optimizing/instruction_simplifier.cc')
-rw-r--r-- | compiler/optimizing/instruction_simplifier.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc index 94b201e876..5d552411db 100644 --- a/compiler/optimizing/instruction_simplifier.cc +++ b/compiler/optimizing/instruction_simplifier.cc @@ -2406,7 +2406,9 @@ static bool IsArrayLengthOf(HInstruction* potential_length, HInstruction* potent void InstructionSimplifierVisitor::SimplifySystemArrayCopy(HInvoke* instruction) { HInstruction* source = instruction->InputAt(0); + HInstruction* source_pos = instruction->InputAt(1); HInstruction* destination = instruction->InputAt(2); + HInstruction* destination_pos = instruction->InputAt(3); HInstruction* count = instruction->InputAt(4); SystemArrayCopyOptimizations optimizations(instruction); if (CanEnsureNotNullAt(source, instruction)) { @@ -2419,6 +2421,10 @@ void InstructionSimplifierVisitor::SimplifySystemArrayCopy(HInvoke* instruction) optimizations.SetDestinationIsSource(); } + if (source_pos == destination_pos) { + optimizations.SetSourcePositionIsDestinationPosition(); + } + if (IsArrayLengthOf(count, source)) { optimizations.SetCountIsSourceLength(); } |