mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2026-02-19 19:36:26 +01:00
+ optimize nil - val into - val
This commit is contained in:
parent
bc2af0d6d6
commit
16a9651046
@ -1018,6 +1018,10 @@ const
|
||||
result := ctypeconvnode.create_internal(cunaryminusnode.create(right.getcopy),right.resultdef);
|
||||
end
|
||||
|
||||
{ change "nil - val" to "-val" }
|
||||
else if (left.nodetype=niln) and is_pointer(right.resultdef) then
|
||||
result := ctypeconvnode.create_internal(cunaryminusnode.create(ctypeconvnode.create_internal(right.getcopy,resultdef)),resultdef)
|
||||
|
||||
{ convert n - n mod const into n div const*const }
|
||||
else if (right.nodetype=modn) and is_constintnode(tmoddivnode(right).right) and
|
||||
(left.isequal(tmoddivnode(right).left)) and not(might_have_sideeffects(left)) { and
|
||||
|
||||
@ -1013,7 +1013,7 @@ implementation
|
||||
|
||||
constructor tunaryminusnode.create(expr : tnode);
|
||||
begin
|
||||
inherited create(unaryminusn,expr);
|
||||
inherited create(unaryminusn,expr);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user