From: Matthew Fortune <matthew.fort...@imgtec.com> gcc/ChangeLog:
* config/mips/mips.cc (mips_expand_block_move): Add support to control size of inlined memcpy. A memcpy strictly less than the limit determined with an option -mblockmov-limit will be considered for inlining. Improve aligned straight line memcpy. * config/mips/mips.h (MIPS_MAX_MOVE_MEM_STRAIGHT): Define macro. * config/mips/mips.opt (mblockmov-limit): New option. Cherry-picked cf1e4960a4f80301e4c8f71a35cbbc8fef1ce6fd, and 4194c529fade9b3106d118cac63b71bc8b13f7be from https://github.com/MIPS/gcc Signed-off-by: Matthew Fortune <matthew.fort...@imgtec.com> Signed-off-by: Robert Suchanek <robert.sucha...@imgtec.com> Signed-off-by: Faraz Shahbazker <fshahbaz...@wavecomp.com> Signed-off-by: Aleksandar Rakic <aleksandar.ra...@htecgroup.com> --- gcc/config/mips/mips.cc | 29 +++++++++++++++++++---------- gcc/config/mips/mips.h | 5 +++++ gcc/config/mips/mips.opt | 3 +++ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc index 6452991c2e1..b838caad4b4 100644 --- a/gcc/config/mips/mips.cc +++ b/gcc/config/mips/mips.cc @@ -9377,16 +9377,25 @@ mips_expand_block_move (rtx dest, rtx src, rtx length) || MEM_ALIGN (dest) < MIPS_MIN_MOVE_MEM_ALIGN)) return false; - if (INTVAL (length) <= MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER) - { - mips_block_move_straight (dest, src, INTVAL (length)); - return true; - } - else if (optimize) - { - mips_block_move_loop (dest, src, INTVAL (length), - MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER); - return true; + if (mips_movmem_limit == -1 || INTVAL (length) < mips_movmem_limit) + { + if (INTVAL (length) <= MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER + /* We increase slightly the maximum number of bytes in + a straight-line block if the source and destination + are aligned to the register width. */ + || (!optimize_size + && INTVAL (alignment) == UNITS_PER_WORD + && INTVAL (length) <= MIPS_MAX_MOVE_MEM_STRAIGHT)) + { + mips_block_move_straight (dest, src, INTVAL (length)); + return true; + } + else if (optimize) + { + mips_block_move_loop (dest, src, INTVAL (length), + MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER); + return true; + } } return false; diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index c1e0e0e2588..df249a79b69 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -3146,6 +3146,11 @@ while (0) #define MIPS_MAX_MOVE_BYTES_STRAIGHT \ (MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER * 2) +/* The maximum number of bytes that can be copied by any expanded block move; + see mips_expand_block_move. */ +#define MIPS_MAX_MOVE_MEM_STRAIGHT \ + (MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER * 3) + /* The base cost of a memcpy call, for MOVE_RATIO and friends. These values were determined experimentally by benchmarking with CSiBE. In theory, the call overhead is higher for TARGET_ABICALLS (especially diff --git a/gcc/config/mips/mips.opt b/gcc/config/mips/mips.opt index 236550c7eb1..4f6f2e9286b 100644 --- a/gcc/config/mips/mips.opt +++ b/gcc/config/mips/mips.opt @@ -552,3 +552,6 @@ munique-sections=FILE Use to specify sections that should be made unique. mfunc-opt-list= Target RejectNegative Joined Var(mips_func_opt_list_file) Init(0) Defer mfunc-opt-list=FILE Use to specify per function optimizations. + +mblockmov-limit= +Target RejectNegative Undocumented Joined UInteger Var(mips_movmem_limit) Init(-1) -- 2.34.1