From: Ulya Trofimovich Date: Wed, 5 Apr 2017 20:56:44 +0000 (+0100) Subject: Fixed tag optimizations to respect tags with history. X-Git-Tag: 1.0~39^2~82 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=503b39386750237dea74e7d6e550df52af0671ab;p=re2c Fixed tag optimizations to respect tags with history. --- diff --git a/re2c/src/dfa/cfg/compact.cc b/re2c/src/dfa/cfg/compact.cc index fcd06820..fe7ce413 100644 --- a/re2c/src/dfa/cfg/compact.cc +++ b/re2c/src/dfa/cfg/compact.cc @@ -19,10 +19,13 @@ tagver_t cfg_t::compact(const cfg_t &cfg, tagver_t *ver2new) for (size_t i = 0; i < cfg.nbbfall; ++i) { const cfg_bb_t &b = cfg.bblocks[i]; for (const tcmd_t *p = b.cmd; p; p = p->next) { - const tagver_t r = p->rhs; + const tagver_t r = p->rhs, h = p->pred; if (tcmd_t::iscopy(r)) { used[r] = true; } + if (h != TAGVER_ZERO) { + used[h] = true; + } used[p->lhs] = true; } } diff --git a/re2c/src/dfa/cfg/interfere.cc b/re2c/src/dfa/cfg/interfere.cc index a83961f1..aedf6576 100644 --- a/re2c/src/dfa/cfg/interfere.cc +++ b/re2c/src/dfa/cfg/interfere.cc @@ -38,15 +38,11 @@ void interfere(const tcmd_t *cmd, const bool *live, bool *interf, cfg_t::live_through_bblock(p->next, buf2); // exclude RHS - if (tcmd_t::iscopy(r)) { - buf2[r] = false; - } + if (tcmd_t::iscopy(r)) buf2[r] = false; // exclude tags assigned to the same RHS for (const tcmd_t *q = cmd; q; q = q->next) { - if (q->rhs == r) { - buf2[q->lhs] = false; - } + if (q->rhs == r) buf2[q->lhs] = false; } const size_t l = static_cast(p->lhs); diff --git a/re2c/src/dfa/cfg/liveanal.cc b/re2c/src/dfa/cfg/liveanal.cc index efe65d9e..f03b3783 100644 --- a/re2c/src/dfa/cfg/liveanal.cc +++ b/re2c/src/dfa/cfg/liveanal.cc @@ -29,11 +29,17 @@ void cfg_t::live_through_bblock(const tcmd_t *cmd, bool *live) live_through_bblock(cmd->next, live); - const tagver_t l = cmd->lhs, r = cmd->rhs; - if (live[l] && tcmd_t::iscopy(r)) { - live[r] = true; + const tagver_t l = cmd->lhs, r = cmd->rhs, p = cmd->pred; + if (live[l]) { + // first reset, than set: LHS might be equal to history + live[l] = false; + if (tcmd_t::iscopy(r)) { + live[r] = true; + } + if (p != TAGVER_ZERO) { + live[p] = true; + } } - live[l] = false; } void cfg_t::liveness_analysis(const cfg_t &cfg, bool *live) diff --git a/re2c/src/dfa/cfg/rename.cc b/re2c/src/dfa/cfg/rename.cc index 56c475a8..25cb5250 100644 --- a/re2c/src/dfa/cfg/rename.cc +++ b/re2c/src/dfa/cfg/rename.cc @@ -12,12 +12,15 @@ void cfg_t::renaming(cfg_t &cfg, const tagver_t *ver2new, tagver_t maxver) cfg_bb_t *b = cfg.bblocks, *be = b + cfg.nbbfall; for (; b < be; ++b) { for (tcmd_t *p, **pp = &b->cmd; (p = *pp);) { - tagver_t &l = p->lhs, &r = p->rhs; + tagver_t &l = p->lhs, &r = p->rhs, &h = p->pred; l = ver2new[l]; if (tcmd_t::iscopy(r)) { r = ver2new[r]; } + if (h != TAGVER_ZERO) { + h = ver2new[h]; + } if (l == r) { *pp = p->next; } else { diff --git a/re2c/src/dfa/cfg/varalloc.cc b/re2c/src/dfa/cfg/varalloc.cc index f92249ba..a50027c8 100644 --- a/re2c/src/dfa/cfg/varalloc.cc +++ b/re2c/src/dfa/cfg/varalloc.cc @@ -35,7 +35,8 @@ tagver_t cfg_t::variable_allocation(const cfg_t &cfg, const bool *interf, for (const tcmd_t *p = b->cmd; p; p = p->next) { x = p->lhs; y = p->rhs; - if (!tcmd_t::iscopy(y)) continue; + if (!tcmd_t::iscopy(y)) y = p->pred; + if (y == TAGVER_ZERO || y == x) continue; rx = repr[x]; ry = repr[y];