]> git.gag.com Git - fw/sdcc/commitdiff
fixed the pointer value caching problem
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 12 Apr 2000 19:03:22 +0000 (19:03 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 12 Apr 2000 19:03:22 +0000 (19:03 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@232 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCBBlock.h
src/SDCCcse.c
src/SDCCcse.h
src/SDCCdflow.c

index b8ad1aab53372c8ddbfa232e4f5ca587d52f70f2..51d53726f0519172e588782f9fe646f1086d19fd 100644 (file)
@@ -61,6 +61,7 @@ typedef struct eBasicBlock {
     bitVect *usesDefs;/* which definitions are used in this block */
     bitVect *ptrsSet; /* pointers assigned values in the block */
     bitVect *inPtrsSet;/* in coming pointers assigned values */
+    bitVect *ndompset; /* pointers set by non-dominating basic blocks */
     set     *addrOf ; /* symbols for which addres has been taken in the block */
     bitVect *linds ;  /* if loop exit this contains defNumbers
                         for the inductions */
index 52efaef7754eb3b3381cc4e22c0572234d8074a5..fea12fb3cd48fc791264aa9d2a1a53e9ef113676 100644 (file)
@@ -81,7 +81,7 @@ int pcseDef (void *item, va_list ap)
 /* replaceAllSymBySym - replaces all operands by operand in an     */
 /*                      instruction chain                          */
 /*-----------------------------------------------------------------*/
-void replaceAllSymBySym (iCode *ic, operand *from , operand *to)
+void replaceAllSymBySym (iCode *ic, operand *from , operand *to, bitVect **ndpset)
 {
     iCode *lic;
 
@@ -122,12 +122,20 @@ void replaceAllSymBySym (iCode *ic, operand *from , operand *to)
            if (POINTER_SET(lic)) {
                bitVectUnSetBit (OP_USES(from),lic->key);
                OP_USES(to) = bitVectSetBit (OP_USES(to),lic->key);
+
+               /* also check if the "from" was in the non-dominating 
+                  pointer sets and replace it with "to" in the bitVector */
+               if (bitVectBitValue(*ndpset,from->key)) {
+                   bitVectUnSetBit(*ndpset,from->key);
+                   bitVectSetBit(*ndpset,to->key);
+               }
+
            }
            else {              
                bitVectUnSetBit (OP_DEFS(from),lic->key);
                OP_DEFS(to) = bitVectSetBit (OP_DEFS(to),lic->key);
-           }
-           siaddr = IC_RESULT(lic)->isaddr ;
+           }       
+           siaddr = IC_RESULT(lic)->isaddr ;       
            IC_RESULT(lic) = operandFromOperand(to);
            IC_RESULT(lic)->isaddr = siaddr ;
        }
@@ -148,7 +156,7 @@ void replaceAllSymBySym (iCode *ic, operand *from , operand *to)
            siaddr = IC_LEFT(lic)->isaddr ;
            IC_LEFT(lic) = operandFromOperand(to);
            IC_LEFT(lic)->isaddr = siaddr ;
-       }
+       }       
     }
 }
 
@@ -183,7 +191,7 @@ DEFSETFUNC(removeFromInExprs)
     ebp->visited = 1;
     deleteItemIf(&ebp->inExprs,iCodeKeyIs,ic->key);
     if (ebp != cbp && !bitVectBitValue(cbp->domVect,ebp->bbnum))
-       replaceAllSymBySym(ebp->sch,from,to);
+       replaceAllSymBySym(ebp->sch,from,to,&ebp->ndompset);
 
     applyToSet(ebp->succList,removeFromInExprs,ic,from,to,cbp);
     return 0;
@@ -1318,7 +1326,8 @@ int cseBBlock ( eBBlock *ebb, int computeOnly,
        pdic = NULL ;   
        if (!( POINTER_GET(ic)                      &&
               (IS_BITFIELD(OP_SYMBOL(IC_RESULT(ic))->etype) ||
-              isOperandVolatile(IC_LEFT(ic),TRUE))) &&
+              isOperandVolatile(IC_LEFT(ic),TRUE)           ||
+              bitVectBitValue(ebb->ndompset,IC_LEFT(ic)->key))) &&
            ! ASSIGNMENT(ic)                        && 
              IS_ITEMP(IC_RESULT(ic))               &&
            ! computeOnly) {
@@ -1333,7 +1342,7 @@ int cseBBlock ( eBBlock *ebb, int computeOnly,
            if (IS_ITEMP(IC_RESULT(ic))) {
 
                /* replace in the remaining of this block */
-               replaceAllSymBySym(ic->next,IC_RESULT(ic),IC_RESULT(pdic));
+               replaceAllSymBySym(ic->next,IC_RESULT(ic),IC_RESULT(pdic),&ebb->ndompset);
                /* remove this iCode from inexpressions of all
                   its successors, it cannot be in the in expressions
                   of any of the predecessors */        
@@ -1347,7 +1356,7 @@ int cseBBlock ( eBBlock *ebb, int computeOnly,
                    eBBlock *owner ;
                    for (owner = setFirstItem(ic->movedFrom); owner ;
                         owner = setNextItem(ic->movedFrom))
-                       replaceAllSymBySym(owner->sch,IC_RESULT(ic),IC_RESULT(pdic));
+                       replaceAllSymBySym(owner->sch,IC_RESULT(ic),IC_RESULT(pdic),&owner->ndompset);
                }
                pdic->movedFrom = unionSets(pdic->movedFrom,ic->movedFrom,THROW_NONE);
            } 
@@ -1399,7 +1408,7 @@ int cseBBlock ( eBBlock *ebb, int computeOnly,
            /* if we find it then locally replace all
               references to the result with what we assigned */
            if (pdop) {
-               replaceAllSymBySym(ic->next,IC_RESULT(ic),pdop);
+               replaceAllSymBySym(ic->next,IC_RESULT(ic),pdop,&ebb->ndompset);
            }
        }
 
index faf0b3ad5c37bed72ff2115caee1be2cd6923c21..e398dcc927f085a3c786125b64b393724023a235 100644 (file)
@@ -54,5 +54,5 @@ void ifxOptimize (iCode *,set *,int,eBBlock *,int *,eBBlock **,int);
 void unsetDefsAndUses ( iCode *) ;
 void updateSpillLocation ( iCode *ic);
 void setUsesDefs (operand *,bitVect *,bitVect *,bitVect **);
-void replaceAllSymBySym (iCode *,operand *,operand *);
+void replaceAllSymBySym (iCode *,operand *,operand *,bitVect **);
 #endif
index 24d13c24ecd520c9d35ab756bd2357e2a2ee13e9..971ed998fa12e8694c66c55b2d8c95d040f1d21a 100644 (file)
@@ -97,18 +97,26 @@ DEFSETFUNC(mergeInExprs)
     /* if in the dominator list then */
     if (bitVectBitValue(dest->domVect,ebp->bbnum) && dest != ebp) {
        /* if already present then intersect */
-       if (!dest->inExprs && *firstTime) 
+       if (!dest->inExprs && *firstTime) {
            dest->inExprs = setFromSet(ebp->outExprs);
-       else
+           /* copy the pointer set from the dominator */
+           dest->inPtrsSet = bitVectCopy(ebp->ptrsSet);
+           dest->ndompset  = bitVectCopy(ebp->ndompset);
+       }
+       else {
            dest->inExprs = intersectSets (dest->inExprs,
                                           ebp->outExprs,
-                                          THROW_DEST);    
-       /* copy the pointer set from the dominator */
-       dest->inPtrsSet = bitVectCopy(ebp->ptrsSet);
+                                          THROW_DEST);  
+           dest->inPtrsSet = bitVectUnion(dest->inPtrsSet,ebp->ptrsSet);
+           dest->ndompset  = bitVectUnion(dest->ndompset,ebp->ndompset);
+       }
     }
-    else 
+    else {
        /* delete only if killed in this block */
        deleteItemIf (&dest->inExprs,ifKilledInBlock, ebp);
+       /* union the ndompset with pointers set in this block*/
+       dest->ndompset = bitVectUnion(dest->ndompset,ebp->ptrsSet);
+    }
     
     *firstTime = 0;