recognize more phis as copies

Not only phi(%a, %a, ...) is a copy
but any argument can also be a self
reference.
This commit is contained in:
Quentin Carbonneaux 2026-05-06 22:14:45 +02:00
parent 1366e70856
commit ade9f31efb

14
copy.c
View File

@ -388,14 +388,20 @@ phicopyref(Fn *fn, Blk *b, Phi *p)
{ {
Blk *d, **s; Blk *d, **s;
Phi *p1; Phi *p1;
Ref r;
uint n, c; uint n, c;
/* identical args */ /* identical args */
for (n=0; n<p->narg-1; n++) r = R;
if (!req(p->arg[n], p->arg[n+1])) for (n=0; n<p->narg; n++)
if (!req(p->arg[n], p->to)) {
if (req(r, R))
r = p->arg[n];
else if (!req(p->arg[n], r))
break; break;
if (n == p->narg-1) }
return p->arg[n]; if (n == p->narg)
return r;
/* same as a previous phi */ /* same as a previous phi */
for (p1=b->phi; p1!=p; p1=p1->link) { for (p1=b->phi; p1!=p; p1=p1->link) {