From a7cb99f0123e7175cfe16df16a5522663217d910 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sun, 25 Nov 2018 20:56:58 +0000 Subject: [PATCH] * when transforming the structure of a node tree involving full boolean evaluation flags, also move the full boolean evaluation flags git-svn-id: trunk@40367 - --- compiler/optcse.pas | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/compiler/optcse.pas b/compiler/optcse.pas index c34da85563..5deb1d2778 100644 --- a/compiler/optcse.pas +++ b/compiler/optcse.pas @@ -329,7 +329,7 @@ unit optcse; (is_set(n.resultdef)) ) then while (n.nodetype=tbinarynode(n).left.nodetype) and - { if node (1) is fully boolean evaluated and node (2) not, we cannot do the swap as is might result in B being evaluated always, + { if node (1) is fully boolean evaluated and node (2) not, we cannot do the swap as this might result in B being evaluated always, the other way round is no problem, C is still evaluated only if needed } (not(is_boolean(n.resultdef)) or not(n.nodetype in [andn,orn]) or doshortbooleval(n) or not(doshortbooleval(tbinarynode(n).left))) and { the resulttypes of the operands we'll swap must be equal, @@ -347,6 +347,17 @@ unit optcse; foreachnodestatic(pm_postprocess,tbinarynode(tbinarynode(n).left).right,@searchsubdomain,@csedomain); if csedomain then begin + { move the full boolean evaluation of (2) to (1), if it was there (so it again applies to A and + what follows) } + if not(doshortbooleval(tbinarynode(n).left)) and + doshortbooleval(n) then + begin + n.localswitches:=n.localswitches+(tbinarynode(n).left.localswitches*[cs_full_boolean_eval]); + exclude(tbinarynode(n).left.localswitches,cs_full_boolean_eval); + tbinarynode(n).left.flags:=tbinarynode(n).left.flags+(n.flags*[nf_short_bool]); + exclude(n.Flags,nf_short_bool); + end; + hp2:=tbinarynode(tbinarynode(n).left).left; tbinarynode(tbinarynode(n).left).left:=tbinarynode(tbinarynode(n).left).right; tbinarynode(tbinarynode(n).left).right:=tbinarynode(n).right;