* when optimizing boolean expressions, might_have_sideeffects is only relevant if the expression would be optimized away

git-svn-id: trunk@44084 -
This commit is contained in:
florian 2020-02-01 18:02:17 +00:00
parent d479069f8c
commit 77b54f501f

View File

@ -1148,7 +1148,7 @@ implementation
containing constants }
if is_boolean(left.resultdef) and is_boolean(right.resultdef) then
begin
if is_constboolnode(left) and not(might_have_sideeffects(right)) then
if is_constboolnode(left) then
begin
if ((nodetype=andn) and (tordconstnode(left).value<>0)) or
((nodetype=orn) and (tordconstnode(left).value=0)) or
@ -1158,8 +1158,9 @@ implementation
right:=nil;
exit;
end
else if ((nodetype=orn) and (tordconstnode(left).value<>0)) or
((nodetype=andn) and (tordconstnode(left).value=0)) then
else if not(might_have_sideeffects(right)) and
(((nodetype=orn) and (tordconstnode(left).value<>0)) or
((nodetype=andn) and (tordconstnode(left).value=0))) then
begin
result:=left;
left:=nil;
@ -1172,7 +1173,7 @@ implementation
exit;
end
end
else if is_constboolnode(right) and not(might_have_sideeffects(left)) then
else if is_constboolnode(right) then
begin
if ((nodetype=andn) and (tordconstnode(right).value<>0)) or
((nodetype=orn) and (tordconstnode(right).value=0)) or
@ -1182,8 +1183,9 @@ implementation
left:=nil;
exit;
end
else if ((nodetype=orn) and (tordconstnode(right).value<>0)) or
((nodetype=andn) and (tordconstnode(right).value=0)) then
else if not(might_have_sideeffects(left)) and
(((nodetype=orn) and (tordconstnode(right).value<>0)) or
((nodetype=andn) and (tordconstnode(right).value=0))) then
begin
result:=right;
right:=nil;