trunk/gcc121/vcs_diff_compiler.patch results

File details

./trunk/gcc121/vcs_diff_compiler.patch 2026-07-20-10:27

Used binaries

   

Binaries version

> uname -a
Linux cfarm121 7.1.3+deb14-powerpc64 #1 SMP PREEMPT Debian 7.1.3-1 (2026-07-04) ppc64 GNU/Linux

Full file content

 
diff --git a/compiler/aoptobj.pas b/compiler/aoptobj.pas
index d2f84daa4d..4ccaa2e546 100644
--- a/compiler/aoptobj.pas
+++ b/compiler/aoptobj.pas
@@ -29,7 +29,7 @@
 
 {$i fpcdefs.inc}
 
-{$if not defined(JVM) and not defined(WASM)}
+{$if not defined(JVM) and not defined(WASM) and not defined(POWERPC) and not defined(POWERPC64)}
 {$define CPU_SUPPORTS_OPT_COND_JUMP}
 {$endif}
 
diff --git a/compiler/powerpc/itcpugas.pas b/compiler/powerpc/itcpugas.pas
index 2fa37cf15c..cb92cc3bab 100644
--- a/compiler/powerpc/itcpugas.pas
+++ b/compiler/powerpc/itcpugas.pas
@@ -126,6 +126,10 @@ implementation
         result:=regnumber_table[findreg_by_gasname(s)];
       end;
 
+{$ifdef ENABLE_OPTS_LOCALLY}
+{$push}
+{$OPTIMIZATION ON}
+{$endif ENABLE_OPTS_LOCALLY}
 
     function gas_regname(r:Tregister):string;
       var
@@ -149,4 +153,8 @@ implementation
           result:=generic_regname(r);
       end;
 
+{$ifdef ENABLE_OPTS_LOCALLY}
+{$pop}
+{$endif ENABLE_OPTS_LOCALLY}
+
 end.
diff --git a/compiler/ppcgen/aasmcpu.pas b/compiler/ppcgen/aasmcpu.pas
index 9d7045ca61..f578dbdea0 100644
--- a/compiler/ppcgen/aasmcpu.pas
+++ b/compiler/ppcgen/aasmcpu.pas
@@ -87,6 +87,7 @@       taicpu = class(tai_cpu_abstract_sym)
          { register spilling code }
          function spilling_get_operation_type(opnr: longint): topertype;override;
          function spilling_get_operation_type_ref(opnr: longint; reg: tregister): topertype;override;
+	 procedure set_is_jmp_flag;
       end;
 
       tai_align = class(tai_align_abstract)
@@ -124,15 +125,22 @@ implementation
       end;
 
 
+    procedure taicpu.set_is_jmp_flag;
+      begin
+         is_jmp:=is_calljmp(opcode);
+      end;
+
+
     constructor taicpu.op_none(op : tasmop);
       begin
          inherited create(op);
+         set_is_jmp_flag;
       end;
 
 
     constructor taicpu.op_reg(op : tasmop;_op1 : tregister);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=1;
          loadreg(0,_op1);
       end;
@@ -140,7 +148,7 @@ implementation
 
     constructor taicpu.op_const(op : tasmop;_op1 : aint);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=1;
          loadconst(0,_op1);
       end;
@@ -148,7 +156,7 @@ implementation
 
     constructor taicpu.op_reg_reg(op : tasmop;_op1,_op2 : tregister);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=2;
          loadreg(0,_op1);
          loadreg(1,_op2);
@@ -156,7 +164,7 @@ implementation
 
     constructor taicpu.op_reg_const(op:tasmop; _op1: tregister; _op2: aint);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=2;
          loadreg(0,_op1);
          loadconst(1,_op2);
@@ -164,7 +172,7 @@ implementation
 
      constructor taicpu.op_const_reg(op:tasmop; _op1: aint; _op2: tregister);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=2;
          loadconst(0,_op1);
          loadreg(1,_op2);
@@ -173,7 +181,7 @@ implementation
 
     constructor taicpu.op_reg_ref(op : tasmop;_op1 : tregister;const _op2 : treference);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=2;
          loadreg(0,_op1);
          loadref(1,_op2);
@@ -182,7 +190,7 @@ implementation
 
     constructor taicpu.op_const_const(op : tasmop;_op1,_op2 : aint);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=2;
          loadconst(0,_op1);
          loadconst(1,_op2);
@@ -191,7 +199,7 @@ implementation
 
     constructor taicpu.op_reg_reg_const_const(op: tasmop; _op1, _op2: tregister; _op3, _op4: aint);
       begin
-        inherited create(op);
+        op_none(op);
         ops := 4;
         loadreg(0, _op1);
         loadreg(1, _op2);
@@ -202,7 +210,7 @@ implementation
 
     constructor taicpu.op_reg_reg_reg(op : tasmop;_op1,_op2,_op3 : tregister);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=3;
          loadreg(0,_op1);
          loadreg(1,_op2);
@@ -211,7 +219,7 @@ implementation
 
      constructor taicpu.op_reg_reg_const(op : tasmop;_op1,_op2 : tregister; _op3: aint);
        begin
-         inherited create(op);
+         op_none(op);
          ops:=3;
          loadreg(0,_op1);
          loadreg(1,_op2);
@@ -220,7 +228,7 @@ implementation
 
      constructor taicpu.op_reg_reg_sym_ofs(op : tasmop;_op1,_op2 : tregister; _op3: tasmsymbol;_op3ofs: aint);
        begin
-         inherited create(op);
+         op_none(op);
          ops:=3;
          loadreg(0,_op1);
          loadreg(1,_op2);
@@ -229,7 +237,7 @@ implementation
 
      constructor taicpu.op_reg_reg_ref(op : tasmop;_op1,_op2 : tregister; const _op3: treference);
        begin
-         inherited create(op);
+         op_none(op);
          ops:=3;
          loadreg(0,_op1);
          loadreg(1,_op2);
@@ -238,7 +246,7 @@ implementation
 
     constructor taicpu.op_const_reg_reg(op : tasmop;_op1 : aint;_op2, _op3 : tregister);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=3;
          loadconst(0,_op1);
          loadreg(1,_op2);
@@ -247,7 +255,7 @@ implementation
 
      constructor taicpu.op_const_reg_const(op : tasmop;_op1 : aint;_op2 : tregister;_op3 : aint);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=3;
          loadconst(0,_op1);
          loadreg(1,_op2);
@@ -257,7 +265,7 @@ implementation
 
      constructor taicpu.op_const_const_const(op : tasmop;_op1 : aint;_op2 : aint;_op3 : aint);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=3;
          loadconst(0,_op1);
          loadconst(1,_op2);
@@ -267,7 +275,7 @@ implementation
 
      constructor taicpu.op_reg_reg_reg_reg(op : tasmop;_op1,_op2,_op3,_op4 : tregister);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=4;
          loadreg(0,_op1);
          loadreg(1,_op2);
@@ -277,7 +285,7 @@ implementation
 
      constructor taicpu.op_reg_bool_reg_reg(op : tasmop;_op1: tregister;_op2:boolean;_op3,_op4:tregister);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=4;
          loadreg(0,_op1);
          loadbool(1,_op2);
@@ -287,7 +295,7 @@ implementation
 
      constructor taicpu.op_reg_bool_reg_const(op : tasmop;_op1: tregister;_op2:boolean;_op3:tregister;_op4: aint);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=4;
          loadreg(0,_op1);
          loadbool(1,_op2);
@@ -297,7 +305,7 @@ implementation
 
      constructor taicpu.op_reg_reg_reg_const(op : tasmop; _op1, _op2, _op3 : tregister; _op4 : aint);
       begin
-        inherited create(op);
+        op_none(op);
 	ops := 4;
 	loadreg(0, _op1);
 	loadreg(1, _op2);
@@ -307,7 +315,7 @@ implementation
 
      constructor taicpu.op_reg_reg_reg_const_const(op : tasmop;_op1,_op2,_op3 : tregister;_op4,_op5 : aint);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=5;
          loadreg(0,_op1);
          loadreg(1,_op2);
@@ -318,7 +326,7 @@ implementation
 
      constructor taicpu.op_reg_reg_const_const_const(op : tasmop;_op1,_op2 : tregister;_op3,_op4,_op5 : aint);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=5;
          loadreg(0,_op1);
          loadreg(1,_op2);
@@ -329,7 +337,7 @@ implementation
 
     constructor taicpu.op_cond_sym(op : tasmop;cond:TAsmCond;_op1 : tasmsymbol);
       begin
-         inherited create(op);
+         op_none(op);
          condition:=cond;
          ops:=1;
          loadsymbol(0,_op1,0);
@@ -337,7 +345,7 @@ implementation
 
      constructor taicpu.op_const_const_sym(op : tasmop;_op1,_op2 : aint; _op3: tasmsymbol);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=3;
          loadconst(0,_op1);
          loadconst(1,_op2);
@@ -347,7 +355,7 @@ implementation
 
     constructor taicpu.op_sym(op : tasmop;_op1 : tasmsymbol);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=1;
          loadsymbol(0,_op1,0);
       end;
@@ -355,7 +363,7 @@ implementation
 
     constructor taicpu.op_sym_ofs(op : tasmop;_op1 : tasmsymbol;_op1ofs:aint);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=1;
          loadsymbol(0,_op1,_op1ofs);
       end;
@@ -363,7 +371,7 @@ implementation
 
      constructor taicpu.op_reg_sym_ofs(op : tasmop;_op1 : tregister;_op2:tasmsymbol;_op2ofs : aint);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=2;
          loadreg(0,_op1);
          loadsymbol(1,_op2,_op2ofs);
@@ -372,7 +380,7 @@ implementation
 
     constructor taicpu.op_sym_ofs_ref(op : tasmop;_op1 : tasmsymbol;_op1ofs:aint;const _op2 : treference);
       begin
-         inherited create(op);
+         op_none(op);
          ops:=2;
          loadsymbol(0,_op1,_op1ofs);
          loadref(1,_op2);
diff --git a/compiler/ppcgen/aoptppc.pas b/compiler/ppcgen/aoptppc.pas
index 6c2dcbb7db..756d74becf 100644
--- a/compiler/ppcgen/aoptppc.pas
+++ b/compiler/ppcgen/aoptppc.pas
@@ -31,6 +31,8 @@
 Type
   TPPCAsmOptimizer = class(TAsmOptimizer)
     function RegLoadedWithNewValue(reg : tregister; hp : tai) : boolean; override;
+    function RegModifiedByInstruction(Reg: TRegister; p1: tai): boolean; override;
+    function InstructionLoadsFromReg(const reg: TRegister; const hp: tai): boolean; override;
  End;
 
 Implementation
@@ -81,5 +83,46 @@   TPPCAsmOptimizer = class(TAsmOptimizer)
           ;
       end;
     end;
+  function TPPCAsmOptimizer.RegModifiedByInstruction(Reg: TRegister; p1: tai): boolean;
+    var
+      i : Longint;
+    begin
+      result:=false;
+      for i:=0 to taicpu(p1).ops-1 do
+        if (taicpu(p1).oper[i]^.typ=top_reg) and (taicpu(p1).oper[i]^.reg=Reg) and (taicpu(p1).spilling_get_operation_type(i) in [operand_write,operand_readwrite]) then
+          begin
+            result:=true;
+            exit;
+          end;
+    end;
+
+ function TPPCAsmOptimizer.InstructionLoadsFromReg(const reg: TRegister; const hp: tai): boolean;
+    var
+      p: taicpu;
+      i: longint;
+    begin
+      result:=false;
+      if not (assigned(hp) and (hp.typ=ait_instruction)) then
+        exit;
+      p:=taicpu(hp);
+
+      i:=0;
+      while(ioperand_write);
+            top_ref:
+              result:=
+                (p.oper[I]^.ref^.base=reg) or
+                (p.oper[I]^.ref^.index=reg);
+            else
+              ;
+          end;
+          if result then exit; {Bailout if we found something}
+          Inc(I);
+        end;
+    end;
+
 
 End.