* src/SDCCopt.c (killDeadCode): do not throw iCodes away if one
[fw/sdcc] / src / SDCCopt.c
index f7e67ce66cf3bd6f195da5534f806dc214ff4b21..1377a58e3243d81f3e251ad408da94734e8a2868 100644 (file)
@@ -879,6 +879,18 @@ killDeadCode (eBBlock ** ebbs, int count)
              if (IC_RESULT (ic) && isOperandVolatile (IC_RESULT (ic), FALSE))
                continue;
 
+             /* We also cannot remove the iCode, when an operand is volatile.       */
+             /* Even read access can cause side effects on some hardware registers! */
+
+             /* if the left operand is volatile then continue */
+             if (IC_LEFT(ic) && isOperandVolatile (IC_LEFT (ic), TRUE))
+               continue;
+
+             /* if the right operand is volatile then continue */
+             if (IC_RIGHT(ic) && isOperandVolatile (IC_RIGHT (ic), TRUE))
+               continue;
+
+
              /* if the result is a temp & isaddr then skip */
              if (IC_RESULT (ic) && POINTER_SET (ic))
                continue;