Browse Source

* tshlshrnode.simplify: in the case of 16-bit or 8-bit shl/shr, AND the right
side constant with 31 (instead of 15 or 7), because that's how the 16-bit and
8-bit x86 shl/shr instructions behave (even on 16-bit CPUs like 286). The
change does not affect 32-bit and 64-bit platforms, because there the shift
is always done in at least 32 bits.

git-svn-id: trunk@27638 -

nickysn 11 years ago
parent
commit
a17797f3ca
1 changed files with 1 additions and 5 deletions
  1. 1 5
      compiler/nmat.pas

+ 1 - 5
compiler/nmat.pas

@@ -592,11 +592,7 @@ implementation
               begin
               begin
                 { shl/shr are unsigned operations, so cut off upper bits }
                 { shl/shr are unsigned operations, so cut off upper bits }
                 case resultdef.size of
                 case resultdef.size of
-                  1:
-                    rvalue:=tordconstnode(right).value and byte($7);
-                  2:
-                    rvalue:=tordconstnode(right).value and byte($f);
-                  4:
+                  1,2,4:
                     rvalue:=tordconstnode(right).value and byte($1f);
                     rvalue:=tordconstnode(right).value and byte($1f);
                   8:
                   8:
                     rvalue:=tordconstnode(right).value and byte($3f);
                     rvalue:=tordconstnode(right).value and byte($3f);