mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-19 20:39:25 +02:00
* optimize away "x mod 1" and "x div 1" + test (ppc code generator handled
"div 1" wrongly) git-svn-id: trunk@3868 -
This commit is contained in:
parent
a49a8ba774
commit
5fa53a1a8c
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -5933,6 +5933,7 @@ tests/test/cg/tloadvmt.pp svneol=native#text/plain
|
||||
tests/test/cg/tlohi.pp svneol=native#text/plain
|
||||
tests/test/cg/tmanypar.pp svneol=native#text/plain
|
||||
tests/test/cg/tmoddiv.pp svneol=native#text/plain
|
||||
tests/test/cg/tmoddiv1.pp svneol=native#text/plain
|
||||
tests/test/cg/tmoddiv2.pp svneol=native#text/plain
|
||||
tests/test/cg/tmul3264.pp svneol=native#text/plain
|
||||
tests/test/cg/tneg.pp svneol=native#text/plain
|
||||
|
@ -107,6 +107,18 @@ implementation
|
||||
begin
|
||||
result:=nil;
|
||||
|
||||
if is_constintnode(right) then
|
||||
begin
|
||||
if tordconstnode(right).value = 1 then
|
||||
case nodetype of
|
||||
modn:
|
||||
result := cordconstnode.create(0,left.resulttype,true);
|
||||
divn:
|
||||
result := left.getcopy;
|
||||
end;
|
||||
exit;
|
||||
end;
|
||||
|
||||
if is_constintnode(right) and is_constintnode(left) then
|
||||
begin
|
||||
rd:=torddef(right.resulttype.def);
|
||||
|
15
tests/test/cg/tmoddiv1.pp
Normal file
15
tests/test/cg/tmoddiv1.pp
Normal file
@ -0,0 +1,15 @@
|
||||
var j,k : integer;
|
||||
|
||||
begin
|
||||
k:=4;
|
||||
if (k div 1 <> 4) then
|
||||
halt(1);
|
||||
j := k div 1;
|
||||
writeln(k div 1, ' ',j);
|
||||
if (k div 1 <> 4) or
|
||||
(j <> 4) then
|
||||
halt(1);
|
||||
if (k mod 1) <> 0 then
|
||||
halt(2);
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user