cvsuser 04/03/22 07:55:28
Modified: imcc pcc.c
Log:
optimize -Oc if only 2 kinds of regs are used
Revision Changes Path
1.56 +36 -12 parrot/imcc/pcc.c
Index: pcc.c
===================================================================
RCS file: /cvs/public/parrot/imcc/pcc.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -w -r1.55 -r1.56
--- pcc.c 22 Mar 2004 13:09:30 -0000 1.55
+++ pcc.c 22 Mar 2004 15:55:28 -0000 1.56
@@ -996,14 +996,14 @@
"pushtopp",
"pushtopn"
};
- char *new_restore[] = {
+ char *new_rest[] = {
"poptopi",
"poptops",
"poptopp",
"poptopn"
};
int needs_save[4], nsave;
- int i, t;
+ int i, t, first;
for (i = 0; i < 4; i++)
needs_save[i] = 0;
@@ -1034,20 +1034,44 @@
ostat.deleted_ins++;
break;
case 1:
+ case 2:
debug(interpreter, DEBUG_OPT1, "opt1 %I => ", ins);
- for (i = 0; i < 4; i++)
- if (needs_save[i])
- break;
+ first = 1;
+ for (i = 0; i < 4; i++) {
+ if (!needs_save[i])
+ continue;
tmp = INS(interpreter, unit, new_save[i], NULL, regs, 0, 0, 0);
+ if (first) {
subst_ins(unit, ins, tmp, 1);
+ ins = tmp;
+ }
+ else {
+ insert_ins(unit, ins, tmp);
+ ins = tmp;
+ }
+ first = 0;
debug(interpreter, DEBUG_OPT1, "%I\n", tmp);
- for (ins = tmp; ins ; ins = ins->next)
+ }
+ for ( ; ins ; ins = ins->next)
if (!strcmp(ins->op, "restoretop"))
break;
+ first = 1;
debug(interpreter, DEBUG_OPT1, "opt1 %I => ", ins);
- tmp = INS(interpreter, unit, new_restore[i], NULL, regs, 0, 0, 0);
+ for (i = 0; i < 4; i++) {
+ if (!needs_save[i])
+ continue;
+ tmp = INS(interpreter, unit, new_rest[i], NULL, regs, 0, 0, 0);
+ if (first) {
subst_ins(unit, ins, tmp, 1);
+ ins = tmp;
+ }
+ else {
+ insert_ins(unit, ins, tmp);
+ ins = tmp;
+ }
+ first = 0;
debug(interpreter, DEBUG_OPT1, "%I\n", tmp);
+ }
break;
}
}