added
[fw/sdcc] / src / SDCCcse.c
index 7f439dc7eba174f70f03c277cd66e9f0a3c01141..a5ea44f393830ed470c338d37be4d7b054051f5a 100644 (file)
@@ -1539,6 +1539,10 @@ cseBBlock (eBBlock * ebb, int computeOnly,
                {
                  if (IS_ITEMP (pdop) || IS_OP_LITERAL (pdop))
                    {
+                       /* some non dominating block does POINTER_SET with
+                          this variable .. unsafe to remove any POINTER_GETs */
+                       if (bitVectBitValue(ebb->ndompset,IC_LEFT(ic)->key))
+                           ebb->ptrsSet = bitVectSetBit(ebb->ptrsSet,pdop->key);
                      IC_LEFT (ic) = pdop;
                      change = 1;
                    }
@@ -1617,12 +1621,18 @@ cseBBlock (eBBlock * ebb, int computeOnly,
 
       /* Alternate code */
       if (pdic && IS_ITEMP(IC_RESULT(ic))) {
+       if (POINTER_GET(ic) && bitVectBitValue(ebb->ptrsSet,IC_LEFT(ic)->key)) {
+         /* Mmm, found an equivalent pointer get at a lower level. 
+            This could be a loop however with the same pointer set 
+            later on */
+       } else {
          /* if previous definition found change this to an assignment */
          ic->op = '=';
          IC_LEFT(ic) = NULL;
          IC_RIGHT(ic) = operandFromOperand(IC_RESULT(pdic));
          SET_ISADDR(IC_RESULT(ic),0);
          SET_ISADDR(IC_RIGHT (ic),0);    
+       }
       }
 
       if (!(POINTER_SET (ic)) && IC_RESULT (ic)) {