mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-09 03:49:05 +02:00
+ function node_not_zero and make use of it
This commit is contained in:
parent
92b3e6a7d7
commit
9cb6497fae
@ -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];
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user