Browse Source

Disable overflow for UDIVX ans SDIVX 64-bit instructions

git-svn-id: trunk@39731 -
pierre 7 years ago
parent
commit
d46536817c
1 changed files with 18 additions and 5 deletions
  1. 18 5
      compiler/sparcgen/ncpumat.pas

+ 18 - 5
compiler/sparcgen/ncpumat.pas

@@ -94,6 +94,7 @@ implementation
          resultreg  : tregister;
          resultreg  : tregister;
          overflowlabel : tasmlabel;
          overflowlabel : tasmlabel;
          ai : taicpu;
          ai : taicpu;
+         no_overflow : boolean;
       begin
       begin
          secondpass(left);
          secondpass(left);
          secondpass(right);
          secondpass(right);
@@ -140,6 +141,14 @@ implementation
 
 
                  op := divops[true, is_signed(right.resultdef),
                  op := divops[true, is_signed(right.resultdef),
                               cs_check_overflow in current_settings.localswitches];
                               cs_check_overflow in current_settings.localswitches];
+                 if op=A_NOP then
+                   { current_asmdata.CurrAsmList.concat(tai_comment.create(strpnew('Wrong code generated here'))); }
+                   begin
+                     no_overflow:=true;
+                     op:=divops[true,is_signed(right.resultdef),false];
+                   end
+                 else
+                   no_overflow:=false;
                  if (divider<>NR_NO) then
                  if (divider<>NR_NO) then
                    current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(op,numerator,divider,resultreg))
                    current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(op,numerator,divider,resultreg))
                  else
                  else
@@ -147,12 +156,16 @@ implementation
 
 
                  if (nodetype = modn) then
                  if (nodetype = modn) then
                    begin
                    begin
-                     current_asmdata.getjumplabel(overflowlabel);
-                     ai:=taicpu.op_cond_sym(A_Bxx,C_VS,overflowlabel);
-                     ai.delayslot_annulled:=true;
-                     current_asmdata.CurrAsmList.concat(ai);
+                     if not no_overflow then
+                       begin
+                         current_asmdata.getjumplabel(overflowlabel);
+                         ai:=taicpu.op_cond_sym(A_Bxx,C_VS,overflowlabel);
+                         ai.delayslot_annulled:=true;
+                         current_asmdata.CurrAsmList.concat(ai);
+                       end;
                      current_asmdata.CurrAsmList.concat(taicpu.op_reg(A_NOT,resultreg));
                      current_asmdata.CurrAsmList.concat(taicpu.op_reg(A_NOT,resultreg));
-                     cg.a_label(current_asmdata.CurrAsmList,overflowlabel);
+                     if not no_overflow then
+                       cg.a_label(current_asmdata.CurrAsmList,overflowlabel);
                      if (divider<>NR_NO) then
                      if (divider<>NR_NO) then
                        current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_MULX,resultreg,divider,resultreg))
                        current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_MULX,resultreg,divider,resultreg))
                      else
                      else