Forráskód Böngészése

m68k: optimize a few cases of comparisons against inlined realconsts

git-svn-id: trunk@33669 -
Károly Balogh 9 éve
szülő
commit
2dbfca4e8e
1 módosított fájl, 26 hozzáadás és 0 törlés
  1. 26 0
      compiler/m68k/aoptcpu.pas

+ 26 - 0
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,31 @@ 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;
             end;
           end;
       end;