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

Modified Files:
        opt_joinpath.mx 
Log Message:
Avoid producing the same joinpath sub-expression.


Index: opt_joinpath.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_joinpath.mx,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- opt_joinpath.mx     11 Jan 2008 10:41:39 -0000      1.15
+++ opt_joinpath.mx     25 Jan 2008 12:00:38 -0000      1.16
@@ -76,13 +76,21 @@
 
        pc= (int*) alloca(sizeof(int)* mb->vtop); /* to find last assignment */
        memset((char*) pc, 0, sizeof(int)* mb->vtop);
-       used= (int*) alloca(sizeof(int)* mb->vtop); /* to find last assignment 
*/
-       memset((char*) used, 0, sizeof(int)* mb->vtop);
 
+       /* calculate how often each variable is used ,
+          we are only expanding when a variable is used once. */
+       used= (int*) alloca(sizeof(int)* mb->vtop); 
+       memset((char*) used, 0, sizeof(int)* mb->vtop);
        for (i = 1; i < mb->stop; i++){
                p= getInstrPtr(mb,i);
+               for(j=p->retc; j< p->argc; j++)
+                       used[getArg(p,j)]++;
                for(j=0; j< p->retc; j++)
                        pc[getArg(p,j)]= i;
+       }
+
+       for (i = 1; i < mb->stop; i++){
+               p= getInstrPtr(mb,i);
                if( getModuleId(p)== algebraRef && getFunctionId(p)== joinRef ){
 @-
 Try to expand each of its argument list
@@ -90,7 +98,7 @@
                        q= copyInstruction(p);
                        q->argc=1;
                        for(j=p->retc; j<p->argc; j++)
-                       if( pc[getArg(p,j)] && used[getArg(p,j)]==0 ){
+                       if( pc[getArg(p,j)] && used[getArg(p,j)]==1 ){
                                r= getInstrPtr(mb,pc[getArg(p,j)]);
 #ifdef DEBUG_OPT_JOINPATH 
                                stream_printf(GDKout,"expand with \n");
@@ -100,9 +108,8 @@
                                        ( getFunctionId(r)== joinRef  || 
getFunctionId(r)== joinPathRef) ){
                                        for(k= r->retc; k<r->argc; k++)
                                                q = 
pushArgument(mb,q,getArg(r,k));
-                               } else {
+                               } else 
                                        q = pushArgument(mb,q,getArg(p,j));
-                               }
                        }
 #ifdef DEBUG_OPT_JOINPATH 
                        stream_printf(GDKout,"new joinPath instruction\n");
@@ -132,10 +139,6 @@
                                actions++;
                        }
                }
-               /* remember its latest use 
-               for(j=p->retc; j<p->argc; j++)
-                       used[getArg(p,j)]= i;
-               */
        }
        return actions;
 }


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to