[release/8.0] [mono][interp] Mask all shift amounts (#90991)
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Wed, 23 Aug 2023 23:03:49 +0000 (16:03 -0700)
committerGitHub <noreply@github.com>
Wed, 23 Aug 2023 23:03:49 +0000 (16:03 -0700)
* [tests] Enable tests

* [mono][interp] Mask all shift amounts

---------

Co-authored-by: Vlad Brezae <brezaevlad@gmail.com>
src/mono/mono/mini/interp/interp-simd.c
src/tests/JIT/HardwareIntrinsics/General/Shared/VectorImmBinaryOperatorTest.template

index 5031c87..f21fdec 100644 (file)
@@ -215,57 +215,57 @@ interp_v128_i2_op_left_shift (gpointer res, gpointer v1, gpointer s1)
 static void
 interp_v128_i4_op_left_shift (gpointer res, gpointer v1, gpointer s1)
 {
-       *(v128_i4*)res = *(v128_i4*)v1 << *(gint32*)s1;
+       *(v128_i4*)res = *(v128_i4*)v1 << (*(gint32*)s1 & 31);
 }
 
 static void
 interp_v128_i8_op_left_shift (gpointer res, gpointer v1, gpointer s1)
 {
-       *(v128_i8*)res = *(v128_i8*)v1 << *(gint32*)s1;
+       *(v128_i8*)res = *(v128_i8*)v1 << (*(gint32*)s1 & 63);
 }
 
 // op_RightShift
 static void
 interp_v128_i1_op_right_shift (gpointer res, gpointer v1, gpointer s1)
 {
-       *(v128_i1*)res = *(v128_i1*)v1 >> *(gint32*)s1;
+       *(v128_i1*)res = *(v128_i1*)v1 >> (*(gint32*)s1 & 7);
 }
 
 static void
 interp_v128_i2_op_right_shift (gpointer res, gpointer v1, gpointer s1)
 {
-       *(v128_i2*)res = *(v128_i2*)v1 >> *(gint32*)s1;
+       *(v128_i2*)res = *(v128_i2*)v1 >> (*(gint32*)s1 & 15);
 }
 
 static void
 interp_v128_i4_op_right_shift (gpointer res, gpointer v1, gpointer s1)
 {
-       *(v128_i4*)res = *(v128_i4*)v1 >> *(gint32*)s1;
+       *(v128_i4*)res = *(v128_i4*)v1 >> (*(gint32*)s1 & 31);
 }
 
 // op_UnsignedRightShift
 static void
 interp_v128_i1_op_uright_shift (gpointer res, gpointer v1, gpointer s1)
 {
-       *(v128_u1*)res = *(v128_u1*)v1 >> *(gint32*)s1;
+       *(v128_u1*)res = *(v128_u1*)v1 >> (*(gint32*)s1 & 7);
 }
 
 static void
 interp_v128_i2_op_uright_shift (gpointer res, gpointer v1, gpointer s1)
 {
-       *(v128_u2*)res = *(v128_u2*)v1 >> *(gint32*)s1;
+       *(v128_u2*)res = *(v128_u2*)v1 >> (*(gint32*)s1 & 15);
 }
 
 static void
 interp_v128_i4_op_uright_shift (gpointer res, gpointer v1, gpointer s1)
 {
-       *(v128_u4*)res = *(v128_u4*)v1 >> *(gint32*)s1;
+       *(v128_u4*)res = *(v128_u4*)v1 >> (*(gint32*)s1 & 31);
 }
 
 static void
 interp_v128_i8_op_uright_shift (gpointer res, gpointer v1, gpointer s1)
 {
-       *(v128_u8*)res = *(v128_u8*)v1 >> *(gint32*)s1;
+       *(v128_u8*)res = *(v128_u8*)v1 >> (*(gint32*)s1 & 63);
 }
 
 // op_OnesComplement
index ff62ffc..d9b2108 100644 (file)
@@ -19,7 +19,6 @@ namespace JIT.HardwareIntrinsics.General
     public static partial class Program
     {
         [Fact]
-        [ActiveIssue("https://github.com/dotnet/runtime/issues/89938", TestRuntimes.Mono)]
         public static void {Method}{RetBaseType}{Imm}()
         {
             var test = new VectorImmBinaryOpTest__{Method}{RetBaseType}{Imm}();