bugfix in load elimination

When checking if two slices represent
the same range of memory we must check
that offsets match.

The bug was revealed by a harec test.
This commit is contained in:
Quentin Carbonneaux 2022-12-13 10:50:27 +01:00
parent 26c1c30b7d
commit 99fea1e211
2 changed files with 52 additions and 0 deletions

2
load.c
View file

@ -248,6 +248,7 @@ def(Slice sl, bits msk, Blk *b, Ins *i, Loc *il)
} else if (i->op == Oblit1) {
assert(rtype(i->arg[0]) == RInt);
sz = abs(rsval(i->arg[0]));
assert(i > b->ins);
--i;
assert(i->op == Oblit0);
r1 = i->arg[1];
@ -321,6 +322,7 @@ def(Slice sl, bits msk, Blk *b, Ins *i, Loc *il)
for (ist=ilog; ist<&ilog[nlog]; ++ist)
if (ist->isphi && ist->bid == b->id)
if (req(ist->new.phi.m.ref, sl.ref))
if (ist->new.phi.m.off == sl.off)
if (ist->new.phi.m.sz == sl.sz) {
r = ist->new.phi.p->to;
if (msk != msks)