Discussion:
Like to contribute
Peter Kuschnerus
2014-03-15 16:53:13 UTC
Permalink
Hello

After I did work with the source code of pcc for longer periods,
now I am familiar with several parts of it.

If it is accepted, I would like to help at several issues.
But I depend on reviewing help.

For instance in module optim.c,
I did find some optimisations
where a comment tells, being not yet ready
because a subroutine tfree is not save for side effects.
So I wrote a new subroutine for this use:

/* as tfree, but handles side effect */
static void
tfreesav(NODE *p)
{
int op, opt;
op = p->n_op;
if (op == ASSIGN)
/* separate side effect */
ecode(p);
else {
opt = coptype(op);
if (opt == BITYPE)
tfreesav(p->n_right);
if (opt != LTYPE)
tfreesav(p->n_left);
nfree(p);
}
}

I tested this tentatively in module local.c and it seems to work.
But I am not quite shure whether the call of ecode is ok in this place.

If it is ok, some little optimisations in optim.c are possible,
using this new subroutine.
For example:

case MUL:
case AND:
/* check *0, &0 */
if ((RCON(p) && RV(p) == 0) || (LCON(p) && LV(p) == 0)) {
/* result zero */
tfreesav(p);
p = bcon(0);
}
break;

Then I consider some further uses for this subroutine in optim.c.


Regards
Peter Kuschnerus
Anders Magnusson
2014-03-20 18:17:46 UTC
Permalink
Hi Peter,

your theory is basically correct, but:
- optim may be called early in the process, hence calling ecode() is not
good here.
- There are lots of other side effects than ASSIGN

what might be better would be to change it to a COMOP, but that needs
good regression tests first.

-- Ragge
Post by Peter Kuschnerus
Hello
After I did work with the source code of pcc for longer periods,
now I am familiar with several parts of it.
If it is accepted, I would like to help at several issues.
But I depend on reviewing help.
For instance in module optim.c,
I did find some optimisations
where a comment tells, being not yet ready
because a subroutine tfree is not save for side effects.
/* as tfree, but handles side effect */
static void
tfreesav(NODE *p)
{
int op, opt;
op = p->n_op;
if (op == ASSIGN)
/* separate side effect */
ecode(p);
else {
opt = coptype(op);
if (opt == BITYPE)
tfreesav(p->n_right);
if (opt != LTYPE)
tfreesav(p->n_left);
nfree(p);
}
}
I tested this tentatively in module local.c and it seems to work.
But I am not quite shure whether the call of ecode is ok in this place.
If it is ok, some little optimisations in optim.c are possible,
using this new subroutine.
/* check *0, &0 */
if ((RCON(p) && RV(p) == 0) || (LCON(p) && LV(p) == 0)) {
/* result zero */
tfreesav(p);
p = bcon(0);
}
break;
Then I consider some further uses for this subroutine in optim.c.
Regards
Peter Kuschnerus
_______________________________________________
Pcc mailing list
http://lists.ludd.ltu.se/cgi-bin/mailman/listinfo/pcc
Peter Kuschnerus
2014-03-31 12:23:51 UTC
Permalink
Post by Anders Magnusson
what might be better would be to change it to a COMOP, but that needs
good regression tests first.
Hi,
Yes I missed some details.

Then I tested using COMOP in optim.c.

I tested successfully the removal of subtrees through COMOP.
Then I tested the not-removal of ASSIGN and CALL in subtrees through COMMOP.
Also successfulliy.

Further I found 9 diffrent cases to optimise wehere to apply COMMOP.
And 5 other cases without COMOP.

I implemented theese and tested it.
Then some regressions should be applied.

Now how to prceed with this ?


Regards
Peter Kuschnerus

Loading...