/* 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;
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 ;
}
siaddr = IC_LEFT(lic)->isaddr ;
IC_LEFT(lic) = operandFromOperand(to);
IC_LEFT(lic)->isaddr = siaddr ;
- }
+ }
}
}
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;
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) {
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 */
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);
}
/* 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);
}
}
/* 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;