Fixed a volatile optimalisation and some other small things
[fw/sdcc] / src / SDCCloop.c
index 453cba1fa728dfe7f359e000042d12ee5ab037f8..ef79a6b90a0df3a210ef3fb3bf002723343ff1c8 100644 (file)
@@ -447,6 +447,11 @@ loopInvariants (region * theLoop, eBBlock ** ebbs, int count)
               IS_OP_PARM (IC_RESULT (ic))))
            continue;
 
+         /* if result depends on a volatile then skip */
+         if ((IC_LEFT(ic) && isOperandVolatile(IC_LEFT(ic), TRUE)) ||
+             (IC_RIGHT(ic) && isOperandVolatile(IC_RIGHT(ic), TRUE)))
+           continue;
+
          lin = rin = 0;
 
          /* special case */
@@ -1161,7 +1166,6 @@ loopOptimizations (hTab * orderedLoops, eBBlock ** ebbs, int count)
   int change = 0;
   int k;
 
-
   /* if no loop optimizations requested */
   if (!optimize.loopInvariant &&
       !optimize.loopInduction)