[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/24] tcg/optimize: Improve find_better_copy
From: |
Richard Henderson |
Subject: |
[PULL 09/24] tcg/optimize: Improve find_better_copy |
Date: |
Wed, 13 Jan 2021 16:16:39 -1000 |
Prefer TEMP_CONST over anything else.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/optimize.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index 16b0aa7229..e42f9c89a8 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -122,31 +122,28 @@ static void init_arg_info(TempOptInfo *infos,
static TCGTemp *find_better_copy(TCGContext *s, TCGTemp *ts)
{
- TCGTemp *i;
+ TCGTemp *i, *g, *l;
- /* If this is already a global, we can't do better. */
- if (ts->kind >= TEMP_GLOBAL) {
+ /* If this is already readonly, we can't do better. */
+ if (temp_readonly(ts)) {
return ts;
}
- /* Search for a global first. */
+ g = l = NULL;
for (i = ts_info(ts)->next_copy; i != ts; i = ts_info(i)->next_copy) {
- if (i->kind >= TEMP_GLOBAL) {
+ if (temp_readonly(i)) {
return i;
- }
- }
-
- /* If it is a temp, search for a temp local. */
- if (ts->kind == TEMP_NORMAL) {
- for (i = ts_info(ts)->next_copy; i != ts; i = ts_info(i)->next_copy) {
- if (i->kind >= TEMP_LOCAL) {
- return i;
+ } else if (i->kind > ts->kind) {
+ if (i->kind == TEMP_GLOBAL) {
+ g = i;
+ } else if (i->kind == TEMP_LOCAL) {
+ l = i;
}
}
}
- /* Failure to find a better representation, return the same temp. */
- return ts;
+ /* If we didn't find a better representation, return the same temp. */
+ return g ? g : l ? l : ts;
}
static bool ts_are_copies(TCGTemp *ts1, TCGTemp *ts2)
--
2.25.1
- [PULL 00/24] tcg patch queue, Richard Henderson, 2021/01/13
- [PULL 01/24] tcg: Use tcg_out_dupi_vec from temp_load, Richard Henderson, 2021/01/13
- [PULL 04/24] tcg: Add temp_readonly, Richard Henderson, 2021/01/13
- [PULL 02/24] tcg: Increase tcg_out_dupi_vec immediate to int64_t, Richard Henderson, 2021/01/13
- [PULL 03/24] tcg: Consolidate 3 bits into enum TCGTempKind, Richard Henderson, 2021/01/13
- [PULL 05/24] tcg: Expand TCGTemp.val to 64-bits, Richard Henderson, 2021/01/13
- [PULL 06/24] tcg: Rename struct tcg_temp_info to TempOptInfo, Richard Henderson, 2021/01/13
- [PULL 07/24] tcg: Expand TempOptInfo to 64-bits, Richard Henderson, 2021/01/13
- [PULL 08/24] tcg: Introduce TYPE_CONST temporaries, Richard Henderson, 2021/01/13
- [PULL 09/24] tcg/optimize: Improve find_better_copy,
Richard Henderson <=
- [PULL 10/24] tcg/optimize: Adjust TempOptInfo allocation, Richard Henderson, 2021/01/13
- [PULL 13/24] tcg: Use tcg_constant_i32 with icount expander, Richard Henderson, 2021/01/13
- [PULL 12/24] tcg: Convert tcg_gen_dupi_vec to TCG_CONST, Richard Henderson, 2021/01/13
- [PULL 19/24] tcg: Add tcg_reg_alloc_dup2, Richard Henderson, 2021/01/13
- [PULL 11/24] tcg/optimize: Use tcg_constant_internal with constant folding, Richard Henderson, 2021/01/13
[PULL 14/24] tcg: Use tcg_constant_{i32,i64} with tcg int expanders, Richard Henderson, 2021/01/13