* 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 -
This commit is contained in:
nickysn 2017-05-01 17:34:19 +00:00
parent 142d95e0d2
commit f26a844b19

View File

@ -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