Procházet zdrojové kódy

* only do the '0*x' and '0 and x' optimization if x has no side effects (except
at -O4, where it is done regardless of whether there are side effects or not)

git-svn-id: trunk@36039 -

nickysn před 8 roky
rodič
revize
f26a844b19
1 změnil soubory, kde provedl 6 přidání a 2 odebrání
  1. 6 2
      compiler/nadd.pas

+ 6 - 2
compiler/nadd.pas

@@ -589,7 +589,9 @@ implementation
                   addn,subn,orn,xorn:
                    result := left.getcopy;
                   andn,muln:
-                   result:=cordconstnode.create(0,resultdef,true);
+                   if (cs_opt_level4 in current_settings.optimizerswitches) or
+                       not might_have_sideeffects(left) then
+                     result:=cordconstnode.create(0,resultdef,true);
                 end;
               end
             else if tordconstnode(right).value = 1 then
@@ -619,7 +621,9 @@ implementation
                   subn:
                    result := cunaryminusnode.create(right.getcopy);
                   andn,muln:
-                   result:=cordconstnode.create(0,right.resultdef,true);
+                   if (cs_opt_level4 in current_settings.optimizerswitches) or
+                       not might_have_sideeffects(right) then
+                     result:=cordconstnode.create(0,right.resultdef,true);
                 end;
               end
             else if tordconstnode(left).value = 1 then