From 23b870908ea31531a2cd82cb3d7af564e957e1be Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Mon, 11 Jul 2022 18:36:10 -0500 Subject: [PATCH] Recognize pc_not as a boolean operation for purposes of optimizations. This generates better code for certain things, like the following assignment: _Bool b = !x; --- DAG.pas | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DAG.pas b/DAG.pas index 95cb44e..fd88103 100644 --- a/DAG.pas +++ b/DAG.pas @@ -1607,7 +1607,7 @@ case op^.opcode of {check for optimizations of this node} else if op^.right^.optype in [cgByte, cgUByte, cgWord, cgUWord] then begin if op^.right^.q = 1 then if op^.left^.opcode in - [pc_and,pc_ior,pc_neq,pc_equ,pc_geq,pc_leq,pc_les,pc_grt] + [pc_and,pc_ior,pc_neq,pc_equ,pc_geq,pc_leq,pc_les,pc_grt,pc_not] then begin opv := op^.left; opv^.next := op^.next; @@ -1616,7 +1616,7 @@ case op^.opcode of {check for optimizations of this node} else if op^.right^.optype in [cgLong, cgULong] then begin if op^.right^.lval = 1 then if op^.left^.opcode in - [pc_and,pc_ior,pc_neq,pc_equ,pc_geq,pc_leq,pc_les,pc_grt] + [pc_and,pc_ior,pc_neq,pc_equ,pc_geq,pc_leq,pc_les,pc_grt,pc_not] then begin opv := op^.left; opv^.next := op^.next; @@ -2126,7 +2126,7 @@ case op^.opcode of {check for optimizations of this node} else if op^.right^.optype in [cgByte, cgUByte, cgWord, cgUWord] then begin if op^.right^.q = 0 then if op^.left^.opcode in - [pc_and,pc_ior,pc_neq,pc_equ,pc_geq,pc_leq,pc_les,pc_grt] + [pc_and,pc_ior,pc_neq,pc_equ,pc_geq,pc_leq,pc_les,pc_grt,pc_not] then begin opv := op^.left; opv^.next := op^.next; @@ -2135,7 +2135,7 @@ case op^.opcode of {check for optimizations of this node} else if op^.right^.optype in [cgLong, cgULong] then begin if op^.right^.lval = 0 then if op^.left^.opcode in - [pc_and,pc_ior,pc_neq,pc_equ,pc_geq,pc_leq,pc_les,pc_grt] + [pc_and,pc_ior,pc_neq,pc_equ,pc_geq,pc_leq,pc_les,pc_grt,pc_not] then begin opv := op^.left; opv^.next := op^.next;