mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-19 23:19:24 +02:00
* 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:
parent
d479069f8c
commit
77b54f501f
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user