Przeglądaj źródła

* first_moddivint should not change the return type if div/mul/add is used
* use create_internal when creating internally add nodes

git-svn-id: trunk@25351 -

florian 12 lat temu
rodzic
commit
e514e84c83
1 zmienionych plików z 10 dodań i 4 usunięć
  1. 10 4
      compiler/arm/narmmat.pas

+ 10 - 4
compiler/arm/narmmat.pas

@@ -91,13 +91,14 @@ implementation
               ispowerof2(tordconstnode(right).value,power) and
               (tordconstnode(right).value<=256) and
               (tordconstnode(right).value>0) then
-              result:=caddnode.create(andn,left,cordconstnode.create(tordconstnode(right).value-1,sinttype,false))
+              result:=caddnode.create_internal(andn,left,cordconstnode.create(tordconstnode(right).value-1,sinttype,false))
             else
               begin
-                result:=caddnode.create(subn,left,caddnode.create(muln,right.getcopy, cmoddivnode.Create(divn,left.getcopy,right.getcopy)));
+                result:=caddnode.create_internal(subn,left,caddnode.create_internal(muln,right,cmoddivnode.Create(divn,left.getcopy,right.getcopy)));
                 right:=nil;
               end;
             left:=nil;
+            firstpass(result);
           end
         else if (nodetype=modn) and
           (is_signed(left.resultdef)) and
@@ -105,13 +106,18 @@ implementation
           (tordconstnode(right).value=2) then
           begin
             // result:=(0-(left and 1)) and (1+(sarlongint(left,31) shl 1))
-            result:=caddnode.create(andn,caddnode.create(subn,cordconstnode.create(0,sinttype,false),caddnode.create(andn,left,cordconstnode.create(1,sinttype,false))),
-                                         caddnode.create(addn,cordconstnode.create(1,sinttype,false),
+            result:=caddnode.create_internal(andn,caddnode.create_internal(subn,cordconstnode.create(0,sinttype,false),caddnode.create_internal(andn,left,cordconstnode.create(1,sinttype,false))),
+                                         caddnode.create_internal(addn,cordconstnode.create(1,sinttype,false),
                                                               cshlshrnode.create(shln,cinlinenode.create(in_sar_x_y,false,ccallparanode.create(cordconstnode.create(31,sinttype,false),ccallparanode.Create(left.getcopy,nil))),cordconstnode.create(1,sinttype,false))));
             left:=nil;
+            firstpass(result);
           end
         else
           result:=inherited first_moddivint;
+
+        { we may not change the result type here }
+        if assigned(result) and (torddef(result.resultdef).ordtype<>torddef(resultdef).ordtype) then
+          inserttypeconv(result,resultdef);
       end;