[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 10/19] tcg/optimize: Improve find_better_copy
From: |
Richard Henderson |
Subject: |
[PATCH v4 10/19] tcg/optimize: Improve find_better_copy |
Date: |
Fri, 8 May 2020 11:26:07 -0700 |
Prefer TEMP_CONST over anything else.
Signed-off-by: Richard Henderson <address@hidden>
---
tcg/optimize.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index c0fc5e3da6..b86bf3d707 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.20.1
- [PATCH v4 01/19] tcg: Consolidate 3 bits into enum TCGTempKind, (continued)
- [PATCH v4 01/19] tcg: Consolidate 3 bits into enum TCGTempKind, Richard Henderson, 2020/05/08
- [PATCH v4 03/19] tcg: Introduce TYPE_CONST temporaries, Richard Henderson, 2020/05/08
- [PATCH v4 04/19] tcg: Use tcg_constant_i32 with icount expander, Richard Henderson, 2020/05/08
- [PATCH v4 06/19] tcg: Use tcg_constant_{i32, vec} with tcg vec expanders, Richard Henderson, 2020/05/08
- [PATCH v4 05/19] tcg: Use tcg_constant_{i32, i64} with tcg int expanders, Richard Henderson, 2020/05/08
- [PATCH v4 07/19] tcg: Use tcg_constant_{i32, i64, vec} with tcg gvec expanders, Richard Henderson, 2020/05/08
- [PATCH v4 08/19] tcg: Use tcg_constant_{i32,i64} with tcg plugins, Richard Henderson, 2020/05/08
- [PATCH v4 09/19] tcg: Rename struct tcg_temp_info to TempOptInfo, Richard Henderson, 2020/05/08
- [PATCH v4 10/19] tcg/optimize: Improve find_better_copy,
Richard Henderson <=
- [PATCH v4 11/19] tcg/optimize: Adjust TempOptInfo allocation, Richard Henderson, 2020/05/08
- [PATCH v4 12/19] tcg/optimize: Use tcg_constant_internal with constant folding, Richard Henderson, 2020/05/08
- [PATCH v4 14/19] tcg: Remove movi and dupi opcodes, Richard Henderson, 2020/05/08
- [PATCH v4 13/19] tcg/tci: Add special tci_movi_{i32,i64} opcodes, Richard Henderson, 2020/05/08
- [PATCH v4 15/19] tcg: Use tcg_out_dupi_vec from temp_load, Richard Henderson, 2020/05/08
- [PATCH v4 16/19] tcg: Increase tcg_out_dupi_vec immediate to int64_t, Richard Henderson, 2020/05/08
- [PATCH v4 18/19] tcg/i386: Use tcg_constant_vec with tcg vec expanders, Richard Henderson, 2020/05/08
- [PATCH v4 17/19] tcg: Add tcg_reg_alloc_dup2, Richard Henderson, 2020/05/08
- [PATCH v4 19/19] tcg: Remove tcg_gen_dup{8,16,32,64}i_vec, Richard Henderson, 2020/05/08