Selaa lähdekoodia

Merged revisions 2890 via svnmerge from
http://[email protected]/svn/fpc/trunk

........
r2890 | florian | 2006-03-12 19:22:11 +0100 (Sun, 12 Mar 2006) | 2 lines

* fix for dword div dword power of two

........

git-svn-id: branches/fixes_2_0@3085 -

peter 19 vuotta sitten
vanhempi
commit
884691fec7
1 muutettua tiedostoa jossa 12 lisäystä ja 7 poistoa
  1. 12 7
      compiler/sparc/ncpumat.pas

+ 12 - 7
compiler/sparc/ncpumat.pas

@@ -100,13 +100,18 @@ implementation
             (right.nodetype = ordconstn) and
             ispowerof2(tordconstnode(right).value,power) then
            begin
-             tmpreg:=cg.GetIntRegister(exprasmlist,OS_INT);
-             cg.a_op_const_reg_reg(exprasmlist,OP_SAR,OS_INT,31,numerator,tmpreg);
-             { if signed, tmpreg=right value-1, otherwise 0 }
-             cg.a_op_const_reg(exprasmlist,OP_AND,OS_INT,tordconstnode(right).value-1,tmpreg);
-             { add to the left value }
-             cg.a_op_reg_reg(exprasmlist,OP_ADD,OS_INT,tmpreg,numerator);
-             cg.a_op_const_reg_reg(exprasmlist,OP_SAR,OS_INT,aword(power),numerator,resultreg);
+             if is_signed(left.resulttype.def) Then
+               begin
+                 tmpreg:=cg.GetIntRegister(exprasmlist,OS_INT);
+                 cg.a_op_const_reg_reg(exprasmlist,OP_SAR,OS_INT,31,numerator,tmpreg);
+                 { if signed, tmpreg=right value-1, otherwise 0 }
+                 cg.a_op_const_reg(exprasmlist,OP_AND,OS_INT,tordconstnode(right).value-1,tmpreg);
+                 { add to the left value }
+                 cg.a_op_reg_reg(exprasmlist,OP_ADD,OS_INT,tmpreg,numerator);
+                 cg.a_op_const_reg_reg(exprasmlist,OP_SAR,OS_INT,aword(power),numerator,resultreg);
+               end
+             else
+               cg.a_op_const_reg_reg(exprasmlist,OP_SHR,OS_INT,aword(power),numerator,resultreg);
            end
          else
            begin