[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 28/35] tcg/optimize: Split out cmp_better_copy
|
From: |
Richard Henderson |
|
Subject: |
[PATCH 28/35] tcg/optimize: Split out cmp_better_copy |
|
Date: |
Mon, 6 Nov 2023 18:48:35 -0800 |
Compare two temps for "better", split out from finding
the best from a whole list. Use TCGKind, which already
gives the proper priority.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/optimize.c | 29 +++++++++++------------------
1 file changed, 11 insertions(+), 18 deletions(-)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index cbb095b241..118561f56d 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -122,6 +122,11 @@ static inline bool ts_is_copy(TCGTemp *ts)
return ts_info(ts)->next_copy != ts;
}
+static TCGTemp *cmp_better_copy(TCGTemp *a, TCGTemp *b)
+{
+ return a->kind < b->kind ? b : a;
+}
+
/* Reset TEMP's state, possibly removing the temp for the list of copies. */
static void reset_ts(OptContext *ctx, TCGTemp *ts)
{
@@ -174,30 +179,20 @@ static void init_ts_info(OptContext *ctx, TCGTemp *ts)
}
}
-static TCGTemp *find_better_copy(TCGContext *s, TCGTemp *ts)
+static TCGTemp *find_better_copy(TCGTemp *ts)
{
- TCGTemp *i, *g, *l;
+ TCGTemp *i, *ret;
/* If this is already readonly, we can't do better. */
if (temp_readonly(ts)) {
return ts;
}
- g = l = NULL;
+ ret = ts;
for (i = ts_info(ts)->next_copy; i != ts; i = ts_info(i)->next_copy) {
- if (temp_readonly(i)) {
- return i;
- } else if (i->kind > ts->kind) {
- if (i->kind == TEMP_GLOBAL) {
- g = i;
- } else if (i->kind == TEMP_TB) {
- l = i;
- }
- }
+ ret = cmp_better_copy(ret, i);
}
-
- /* If we didn't find a better representation, return the same temp. */
- return g ? g : l ? l : ts;
+ return ret;
}
static bool ts_are_copies(TCGTemp *ts1, TCGTemp *ts2)
@@ -672,12 +667,10 @@ static void init_arguments(OptContext *ctx, TCGOp *op,
int nb_args)
static void copy_propagate(OptContext *ctx, TCGOp *op,
int nb_oargs, int nb_iargs)
{
- TCGContext *s = ctx->tcg;
-
for (int i = nb_oargs; i < nb_oargs + nb_iargs; i++) {
TCGTemp *ts = arg_temp(op->args[i]);
if (ts_is_copy(ts)) {
- op->args[i] = temp_arg(find_better_copy(s, ts));
+ op->args[i] = temp_arg(find_better_copy(ts));
}
}
}
--
2.34.1
- [PATCH 21/35] tcg/mips: Always implement movcond, (continued)
- [PATCH 21/35] tcg/mips: Always implement movcond, Richard Henderson, 2023/11/06
- [PATCH 06/35] host/include/loongarch64: Add atomic16 load and store, Richard Henderson, 2023/11/06
- [PATCH 22/35] tcg: Remove TCG_TARGET_HAS_movcond_{i32,i64}, Richard Henderson, 2023/11/06
- [PATCH 23/35] tcg/mips: Implement neg opcodes, Richard Henderson, 2023/11/06
- [PATCH 24/35] tcg/loongarch64: Implement neg opcodes, Richard Henderson, 2023/11/06
- [PATCH 26/35] tcg: Don't free vector results, Richard Henderson, 2023/11/06
- [PATCH 27/35] tcg/optimize: Pipe OptContext into reset_ts, Richard Henderson, 2023/11/06
- [PATCH 29/35] tcg/optimize: Optimize env memory operations, Richard Henderson, 2023/11/06
- [PATCH 30/35] tcg: Eliminate duplicate env store operations, Richard Henderson, 2023/11/06
- [PATCH 25/35] tcg: Remove TCG_TARGET_HAS_neg_{i32,i64}, Richard Henderson, 2023/11/06
- [PATCH 28/35] tcg/optimize: Split out cmp_better_copy,
Richard Henderson <=
- [PATCH 31/35] tcg/optimize: Split out arg_new_constant, Richard Henderson, 2023/11/06
- [PATCH 32/35] tcg: Canonicalize subi to addi during opcode generation, Richard Henderson, 2023/11/06
- [PATCH 33/35] tcg/optimize: Canonicalize subi to addi during optimization, Richard Henderson, 2023/11/06
- [PATCH 34/35] tcg/optimize: Canonicalize sub2 with constants to add2, Richard Henderson, 2023/11/06
- [PATCH 35/35] tcg/sparc64: Implement tcg_out_extrl_i64_i32, Richard Henderson, 2023/11/06
- [PULL 00/35] tcg patch queue, Richard Henderson, 2023/11/06
- Re: [PATCH 00/35] tcg patch queue, Stefan Hajnoczi, 2023/11/07