mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-09 09:11:05 +00:00
Merge if and goto blocks when if only skips over the goto.
This commit is contained in:
parent
6afdfb5fac
commit
3da44ace52
1 changed files with 25 additions and 1 deletions
|
@ -296,6 +296,23 @@ is_conditional (statement_t *s)
|
||||||
return !strncmp (s->opcode, "<IF", 3);
|
return !strncmp (s->opcode, "<IF", 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
invert_conditional (statement_t *s)
|
||||||
|
{
|
||||||
|
if (!strcmp (s->opcode, "<IF>"))
|
||||||
|
s->opcode = "<IFNOT>";
|
||||||
|
else if (!strcmp (s->opcode, "<IFNOT>"))
|
||||||
|
s->opcode = "<IF>";
|
||||||
|
else if (!strcmp (s->opcode, "<IFBE>"))
|
||||||
|
s->opcode = "<IFA>";
|
||||||
|
else if (!strcmp (s->opcode, "<IFB>"))
|
||||||
|
s->opcode = "<IFAE>";
|
||||||
|
else if (!strcmp (s->opcode, "<IFAE>"))
|
||||||
|
s->opcode = "<IFB>";
|
||||||
|
else if (!strcmp (s->opcode, "<IFA>"))
|
||||||
|
s->opcode = "<IFBE>";
|
||||||
|
}
|
||||||
|
|
||||||
typedef sblock_t *(*statement_f) (sblock_t *, expr_t *);
|
typedef sblock_t *(*statement_f) (sblock_t *, expr_t *);
|
||||||
typedef sblock_t *(*expr_f) (sblock_t *, expr_t *, operand_t **);
|
typedef sblock_t *(*expr_f) (sblock_t *, expr_t *, operand_t **);
|
||||||
|
|
||||||
|
@ -1109,7 +1126,14 @@ remove_dead_blocks (sblock_t *blocks)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
s = (statement_t *) sblock->tail;
|
s = (statement_t *) sblock->tail;
|
||||||
if (!is_goto (s) && !is_return (s)) {
|
if (is_conditional (s) && is_goto (sb->statements)
|
||||||
|
&& s->opb->o.label->dest == sb->next) {
|
||||||
|
debug (0, "meging if/goto %p %p", sblock, sb);
|
||||||
|
if (!--s->opb->o.label->used)
|
||||||
|
remove_label_from_dest (s->opb->o.label);
|
||||||
|
s->opb->o.label = sb->statements->opa->o.label;
|
||||||
|
invert_conditional (s);
|
||||||
|
} else if (!is_goto (s) && !is_return (s)) {
|
||||||
sb->reachable = 1;
|
sb->reachable = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue