summaryrefslogtreecommitdiff
path: root/compiler/m68k/aoptcpu.pas
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/m68k/aoptcpu.pas')
-rw-r--r--compiler/m68k/aoptcpu.pas38
1 files changed, 38 insertions, 0 deletions
diff --git a/compiler/m68k/aoptcpu.pas b/compiler/m68k/aoptcpu.pas
index 4307c691f7..39ffcc9015 100644
--- a/compiler/m68k/aoptcpu.pas
+++ b/compiler/m68k/aoptcpu.pas
@@ -60,6 +60,7 @@ unit aoptcpu;
var
next: tai;
tmpref: treference;
+ tmpsingle: single;
begin
result:=false;
case p.typ of
@@ -135,6 +136,43 @@ unit aoptcpu;
taicpu(p).ops:=1;
result:=true;
end;
+ A_FCMP:
+ if (taicpu(p).oper[0]^.typ = top_realconst) then
+ begin
+ if (taicpu(p).oper[0]^.val_real = 0.0) then
+ begin
+ DebugMsg('Optimizer: FCMP #0.0 to FTST',p);
+ taicpu(p).opcode:=A_FTST;
+ taicpu(p).opsize:=S_FX;
+ taicpu(p).loadoper(0,taicpu(p).oper[1]^);
+ taicpu(p).clearop(1);
+ taicpu(p).ops:=1;
+ result:=true;
+ end
+ else
+ begin
+ tmpsingle:=taicpu(p).oper[0]^.val_real;
+ if (taicpu(p).opsize = S_FD) and
+ ((taicpu(p).oper[0]^.val_real - tmpsingle) = 0.0) then
+ begin
+ DebugMsg('Optimizer: FCMP const to lesser precision',p);
+ taicpu(p).opsize:=S_FS;
+ result:=true;
+ end;
+ end;
+ end;
+ A_FMOVE,A_FMUL,A_FADD,A_FSUB,A_FDIV:
+ if (taicpu(p).oper[0]^.typ = top_realconst) then
+ begin
+ tmpsingle:=taicpu(p).oper[0]^.val_real;
+ if (taicpu(p).opsize = S_FD) and
+ ((taicpu(p).oper[0]^.val_real - tmpsingle) = 0.0) then
+ begin
+ DebugMsg('Optimizer: FMOVE/FMUL/FADD/FSUB/FDIV const to lesser precision',p);
+ taicpu(p).opsize:=S_FS;
+ result:=true;
+ end;
+ end;
end;
end;
end;