diff options
author | Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> | 2023-05-25 15:23:57 +0530 |
---|---|---|
committer | Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> | 2023-05-25 15:23:57 +0530 |
commit | ea9154dbc8fc86d4c617503ca5e6f02fed3a6a56 (patch) | |
tree | a07cf555088b6475ffb82d64ed3b7856195ec034 | |
parent | 0d1e0d7433c2c625d67c58fca435b0ffeab8c8ba (diff) | |
download | gcc-ea9154dbc8fc86d4c617503ca5e6f02fed3a6a56.zip gcc-ea9154dbc8fc86d4c617503ca5e6f02fed3a6a56.tar.gz gcc-ea9154dbc8fc86d4c617503ca5e6f02fed3a6a56.tar.bz2 |
[aarch64] Ignore cost of scalar moves for seq in vector initialization.
gcc/ChangeLog:
* config/aarch64/aarch64.cc (scalar_move_insn_p): New function.
(seq_cost_ignoring_scalar_moves): Likewise.
(aarch64_expand_vector_init): Call seq_cost_ignoring_scalar_moves.
-rw-r--r-- | gcc/config/aarch64/aarch64.cc | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 146c2ad..5b046d3 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -22332,6 +22332,45 @@ aarch64_unzip_vector_init (machine_mode mode, rtx vals, bool even_p) return gen_rtx_PARALLEL (new_mode, vec); } +/* Return true if SET is a scalar move. */ + +static bool +scalar_move_insn_p (rtx set) +{ + rtx src = SET_SRC (set); + rtx dest = SET_DEST (set); + return (is_a<scalar_mode> (GET_MODE (dest)) + && aarch64_mov_operand (src, GET_MODE (dest))); +} + +/* Similar to seq_cost, but ignore cost for scalar moves. */ + +static unsigned +seq_cost_ignoring_scalar_moves (const rtx_insn *seq, bool speed) +{ + unsigned cost = 0; + + for (; seq; seq = NEXT_INSN (seq)) + if (NONDEBUG_INSN_P (seq)) + { + if (rtx set = single_set (seq)) + { + if (!scalar_move_insn_p (set)) + cost += set_rtx_cost (set, speed); + } + else + { + int this_cost = insn_cost (CONST_CAST_RTX_INSN (seq), speed); + if (this_cost > 0) + cost += this_cost; + else + cost++; + } + } + + return cost; +} + /* Expand a vector initialization sequence, such that TARGET is initialized to contain VALS. */ @@ -22367,7 +22406,7 @@ aarch64_expand_vector_init (rtx target, rtx vals) halves[i] = gen_rtx_SUBREG (mode, tmp_reg, 0); rtx_insn *rec_seq = get_insns (); end_sequence (); - costs[i] = seq_cost (rec_seq, !optimize_size); + costs[i] = seq_cost_ignoring_scalar_moves (rec_seq, !optimize_size); emit_insn (rec_seq); } @@ -22384,7 +22423,8 @@ aarch64_expand_vector_init (rtx target, rtx vals) start_sequence (); aarch64_expand_vector_init_fallback (target, vals); rtx_insn *fallback_seq = get_insns (); - unsigned fallback_seq_cost = seq_cost (fallback_seq, !optimize_size); + unsigned fallback_seq_cost + = seq_cost_ignoring_scalar_moves (fallback_seq, !optimize_size); end_sequence (); emit_insn (seq_total_cost < fallback_seq_cost ? seq : fallback_seq); |