Skip to content

Vector256.Shuffle() returns incorrect result when index is out of bounds #85132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DeepakRajendrakumaran opened this issue Apr 21, 2023 · 2 comments
Assignees

Comments

@DeepakRajendrakumaran
Copy link
Contributor

DeepakRajendrakumaran commented Apr 21, 2023

Description

Vector256.Shuffle() returns incorrect result when index is out of bounds. When index is out of bounds, expected to return 0 for that and rest of values correctly

Reproduction Steps

using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Numerics;

namespace InterfaceMain
{
    interface Program
    {
          public static unsafe int Main()
        {

            Vector256<int> v256Shuffle1 = Vector256.Create(100, 101, 102, 103, 104, 105, 106, 107);
            Vector256<int> resultElements256Shuffle = Vector256Shuffle(v256Shuffle1);
            Console.Write("\n Vector256Shuffle [ ");
            for (int index = 0; index < Vector256<int>.Count; index++)
            {
                Console.Write(resultElements256Shuffle[index] + ", ");
            }
            Console.Write("]\n Vector256Shuffle Done \n");




            return 100;
        }

        

        [MethodImpl(MethodImplOptions.NoInlining)]
        public static unsafe Vector256<int> Vector256Shuffle(Vector256<int> v1)
        {
            return Vector256.Shuffle(v1, Vector256.Create(7, 555, 3, 1, 6, 4, 2, 0));
        }

    }
}

Expected behavior

Not crash and return 0 for out of bound index

Actual behavior

Crashed on latest main for Debug build

on 7.0, returns incorrect value on sharplab(release?) :

Vector256Suffle [ 107, 0, 103, 101, 0, 0, 0, 0, ]
 Vector256Shuffle Done 

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Apr 21, 2023
@ghost
Copy link

ghost commented Apr 21, 2023

Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Vector256.Shuffle() returns incorrect result when index is out of bounds. When index is out of bounds, expected to return 0 for that and rest of values correctly

Reproduction Steps

using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Numerics;

namespace InterfaceMain
{
    interface Program
    {
          public static unsafe int Main()
        {

            Vector256<int> v256Shuffle1 = Vector256.Create(100, 101, 102, 103, 104, 105, 106, 107);
            Vector256<int> resultElements256Shuffle = Vector256Shuffle(v256Shuffle1);
            Console.Write("\n Vector256Shuffle [ ");
            for (int index = 0; index < Vector256<int>.Count; index++)
            {
                Console.Write(resultElements256Shuffle[index] + ", ");
            }
            Console.Write("]\n Vector256Shuffle Done \n");




            return 100;
        }

        

        [MethodImpl(MethodImplOptions.NoInlining)]
        public static unsafe Vector256<int> Vector256Shuffle(Vector256<int> v1)
        {
            return Vector256.Shuffle(v1, Vector256.Create(7, 555, 3, 1, 6, 4, 2, 0));
        }

    }
}

Expected behavior

Not crash and return 0 for out of bound index

Actual behavior

Crashed on latest main

on 7.0, returns incorrect value :

Vector256Suffle [ 107, 0, 103, 101, 0, 0, 0, 0, ]
 Vector256Shuffle Done 

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: DeepakRajendrakumaran
Assignees: -
Labels:

area-System.Numerics, untriaged

Milestone: -

@ghost ghost added in-pr There is an active PR which will close this issue when it is merged and removed in-pr There is an active PR which will close this issue when it is merged labels May 18, 2023
@tannergooding
Copy link
Member

This was resolved in #86453

@ghost ghost removed the untriaged New issue has not been triaged by the area owner label May 26, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jun 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants