mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-18 15:07:16 +00:00
tcg/optimize: Improve find_better_copy
Prefer TEMP_CONST over anything else. Backports 4c868ce6454872d395b29de8d82387b2ad14aeeb
This commit is contained in:
parent
8edc9b76dd
commit
e751b45aea
|
@ -126,31 +126,28 @@ static void init_arg_info(TCGContext *s, TCGArg arg)
|
||||||
|
|
||||||
static TCGTemp *find_better_copy(TCGTemp *ts)
|
static TCGTemp *find_better_copy(TCGTemp *ts)
|
||||||
{
|
{
|
||||||
TCGTemp *i;
|
TCGTemp *i, *g, *l;
|
||||||
|
|
||||||
/* If this is already a global, we can't do better. */
|
/* If this is already readonly, we can't do better. */
|
||||||
if (ts->kind >= TEMP_GLOBAL) {
|
if (temp_readonly(ts)) {
|
||||||
return 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) {
|
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;
|
return i;
|
||||||
}
|
} else if (i->kind > ts->kind) {
|
||||||
}
|
if (i->kind == TEMP_GLOBAL) {
|
||||||
|
g = i;
|
||||||
/* If it is a temp, search for a temp local. */
|
} else if (i->kind == TEMP_LOCAL) {
|
||||||
if (ts->kind == TEMP_NORMAL) {
|
l = i;
|
||||||
for (i = ts_info(ts)->next_copy; i != ts; i = ts_info(i)->next_copy) {
|
|
||||||
if (i->kind >= TEMP_LOCAL) {
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Failure to find a better representation, return the same temp. */
|
/* If we didn't find a better representation, return the same temp. */
|
||||||
return ts;
|
return g ? g : l ? l : ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ts_are_copies(TCGTemp *ts1, TCGTemp *ts2)
|
static bool ts_are_copies(TCGTemp *ts1, TCGTemp *ts2)
|
||||||
|
|
Loading…
Reference in a new issue