Update of /cvsroot/monetdb/MonetDB5/src/optimizer
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19848

Modified Files:
        opt_commonTerms.mx opt_aliases.mx 
Log Message:
fixed bug in commonTerms optimizer. Exported functions form opt_aliases
are reused now.


Index: opt_aliases.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_aliases.mx,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- opt_aliases.mx      28 Jul 2007 01:52:04 -0000      1.17
+++ opt_aliases.mx      20 Dec 2007 08:46:03 -0000      1.18
@@ -71,6 +71,8 @@
 /* #define DEBUG_OPT_ALIASES      show partial result */
 
 opt_export int OPTaliasStep(MalBlkPtr mb, int pc);
+opt_export int OPTisAlias(InstrPtr p);
+opt_export void OPTaliasRemap(InstrPtr p, int *alias);
 @-
 When you propagate an alias through the program, the properties
 maintained should also be updated. In particular, the lifespan
@@ -88,7 +90,7 @@
 @c
 #include "mal_config.h"
 #include "opt_aliases.h"
-static int
+int
 OPTisAlias(InstrPtr p){
        if( p->token == ASSIGNsymbol &&
                p->barrier == 0 && 
@@ -97,11 +99,11 @@
        return FALSE;
 }
 
-static void
-OPTremap(InstrPtr p, int *alias){
+void
+OPTaliasRemap(InstrPtr p, int *alias){
        int i;
-       for(i=0;i<p->argc; i++)
-               getArg(p,i)= alias[getArg(p,i)];
+       for(i=0; i<p->argc; i++)
+               getArg(p,i) = alias[getArg(p,i)];
 }
 
 static int
@@ -115,11 +117,11 @@
        for(i=0; i<mb->vtop; i++) alias[i]=i;
 
        setLifespan(mb);
-       limit= mb->stop;
+       limit = mb->stop;
        for (i = 1; i < limit; i++){
                p= getInstrPtr(mb,i);
-               mb->stmt[k++]= p;
-               if( OPTisAlias(p)){
+               mb->stmt[k++] = p;
+               if (OPTisAlias(p)){
                        if( getLastUpdate(mb,getArg(p,0)) == i  &&
                                getBeginLifespan(mb,getArg(p,0)) == i  &&
                                getLastUpdate(mb,getArg(p,1)) < i ){
@@ -127,10 +129,12 @@
                                freeInstruction(p);
                                actions++;
                                k--;
-                       } else
-                               OPTremap(p,alias);
-               } else
-                       OPTremap(p,alias);
+                       } else {
+                               OPTaliasRemap(p,alias);
+                       }
+               } else {
+                       OPTaliasRemap(p,alias);
+               }
        }
        for(i=k; i<limit; i++)
                mb->stmt[i]= NULL;

Index: opt_commonTerms.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_commonTerms.mx,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- opt_commonTerms.mx  31 Oct 2007 07:16:25 -0000      1.20
+++ opt_commonTerms.mx  20 Dec 2007 08:46:02 -0000      1.21
@@ -108,11 +108,12 @@
        memset((void*) filter, 0, 1024 * sizeof(int));
 
        alias= (int*) alloca(sizeof(int)* mb->vtop);
-       for(i=0; i<mb->vtop; i++) alias[i]=i;
+       for(i=0; i<mb->vtop; i++) 
+               alias[i]=i;
 
        setLifespan(mb);
-       old= mb->stmt;
-       limit= mb->stop;
+       old = mb->stmt;
+       limit = mb->stop;
        newMalBlkStmt(mb, mb->ssize); /* a new statement stack */
        for ( n= i = 0; i < limit; i++) {
                p = old[i];
@@ -121,27 +122,29 @@
 @-
 First apply alias propagation, before considering a match.
 @c
-               if( p->token == ENDsymbol){
+               if (p->token == ENDsymbol){
                        for(i++; i<limit; i++)
-                       if(old[i])
-                               pushInstruction(mb,old[i]);
+                               if(old[i])
+                                       pushInstruction(mb,old[i]);
                        break;
                }
-               if( p->token == NOOPsymbol) continue;
-               if( p->token == ASSIGNsymbol && p->argc== 2 && p->barrier==0){
-                       if( getLastUpdate(mb,getArg(p,0)) == i &&
+               if (p->token == NOOPsymbol) 
+                       continue;
+               if (OPTisAlias(p)){
+                       if (getLastUpdate(mb,getArg(p,0)) == i &&
                                getBeginLifespan(mb,getArg(p,0)) == i &&
                                getLastUpdate(mb,getArg(p,1)) < i){
-                                       alias[getArg(p,0)]= alias[getArg(p,1)];
+                                       alias[getArg(p,0)] = alias[getArg(p,1)];
                                        freeInstruction(p);
                                        mb->stop--;
                                        mb->stmt[mb->stop]=0;
                                        n--;
                                        continue;
+                       } else {
+                               OPTaliasRemap(p,alias);
                        }
                } else {
-                       for(j=0; j<p->argc; j++)
-                               getArg(p,j)= alias[getArg(p,j)];
+                       OPTaliasRemap(p,alias);
                }
 @-
 Use a hash filter to speed up matching
@@ -149,7 +152,7 @@
                c = p->argc;
                for(j=p->retc; j<p->argc; j++){
                        c *= 4;
-                       if( !isConstant(mb,getArg(p,j)) )
+                       if (!isConstant(mb,getArg(p,j)))
                                c += getArg(p,j);
                }
                c &= 1023;
@@ -163,12 +166,12 @@
 multiple occurrences of the same constant in the symbol table.
 @c
                        last=1;
-                       for( j = p->retc; j<p->argc; j++)
-                       if( getBeginLifespan(mb,getArg(p,j)) > last )
-                               last = getBeginLifespan(mb,getArg(p,j));
+                       for (j = p->retc; j<p->argc; j++)
+                               if( getBeginLifespan(mb,getArg(p,j)) > last )
+                                       last = getBeginLifespan(mb,getArg(p,j));
 
                        for (j = (n-1) - 1; j >= last-(i-(n-1)) && j>0; j--) 
-                       if( mask[j] == c ){
+                       if (mask[j] == c ){
                                if (safetyBarrier(p, q = getInstrPtr(mb, j)))
                                        break;
 #ifdef DEBUG_OPT_COMMONTERMS


-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to