+ function node_not_zero and make use of it

This commit is contained in:
florian 2025-02-08 20:07:06 +01:00
parent 92b3e6a7d7
commit 9cb6497fae
2 changed files with 12 additions and 3 deletions

View File

@ -81,7 +81,7 @@ implementation
aasmbase,aasmdata,
cgbase,pass_2,
cpubase,procinfo,
nadd,ncon,ncal,
nadd,ncon,ncal,nutils,
tgobj,ncgutil,
cgutils,cgobj,hlcgobj,
defcmp
@ -999,8 +999,7 @@ implementation
opsize: tcgsize;
begin
reverse:=(inlinenumber = in_bsr_x);
not_zero:=(left.nodetype=orn) and (((is_constintnode(taddnode(left).left) and (tordconstnode(taddnode(left).left).value<>0))) or
((is_constintnode(taddnode(left).right) and (tordconstnode(taddnode(left).right).value<>0))));
not_zero:=node_not_zero(left);
secondpass(left);
opsize:=tcgsize2unsigned[left.location.size];

View File

@ -214,6 +214,9 @@ interface
{ Returns True if n one of its children has a type that appears in TypeList }
function has_node_of_type(n: TNode; TypeList: TNodeTypeSet): Boolean; {$IFDEF USEINLINE}inline;{$ENDIF USEINLINE}
{ returns true if n is guranteed not to return an ordinal zero }
function node_not_zero(n : tnode) : Boolean;
implementation
@ -1727,4 +1730,11 @@ implementation
Result := foreachnodestatic(n, @node_in_list, @TypeList);
end;
function node_not_zero(n: tnode): Boolean;
begin
result:=(is_constintnode(n) and (get_int_value(n)<>0)) or
((n.nodetype=orn) and (node_not_zero(taddnode(n).left) or node_not_zero(taddnode(n).right)));
end;
end.