Browse Source

* in the optimization of signed division by power-of-2 constant in
tmoddivnode.firstoptimize, replaced tordconstnode(right).value-1 with
tcgint((qword(1) shl power)-1), so that it becomes independent from the sign
of right, so that in the future, we can also apply this optimization for
negative power-of-2 divisors as well (only a unary minus node would have to
be inserted in this case).

git-svn-id: trunk@36845 -

nickysn 8 years ago
parent
commit
a1928859b3
1 changed files with 3 additions and 3 deletions
  1. 3 3
      compiler/nmat.pas

+ 3 - 3
compiler/nmat.pas

@@ -531,8 +531,8 @@ implementation
                      left));
                      left));
                     left:=nil;
                     left:=nil;
 
 
-                    { masknode is (sar(temp,shiftval) and (tordconstnode(right).value-1))
-                      for tordconstnode(right).value=2, masknode is simply (temp shr shiftval)}
+                    { masknode is (sar(temp,shiftval) and ((1 shl power)-1))
+                      for power=1 (i.e. division by 2), masknode is simply (temp shr shiftval)}
                     if power=1 then
                     if power=1 then
                       masknode:=
                       masknode:=
                         cshlshrnode.create(shrn,
                         cshlshrnode.create(shrn,
@@ -546,7 +546,7 @@ implementation
                             ccallparanode.create(cordconstnode.create(shiftval,u8inttype,false),
                             ccallparanode.create(cordconstnode.create(shiftval,u8inttype,false),
                             ccallparanode.create(ctemprefnode.create(temp),nil))
                             ccallparanode.create(ctemprefnode.create(temp),nil))
                           ),
                           ),
-                          cordconstnode.create(tordconstnode(right).value-1,
+                          cordconstnode.create(tcgint((qword(1) shl power)-1),
                             right.resultdef,false)
                             right.resultdef,false)
                         );
                         );