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;
This commit is contained in:
Stephen Heumann 2022-07-11 18:36:10 -05:00
parent 753c9b9f20
commit 23b870908e

View File

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