Skip to content

MonoInterpreter doesn't correctly handle overshifting of a vector #89938

@tannergooding

Description

@tannergooding

As found in #89339, monointerpreter does not currently correctly mask the shiftAmount and produces an incorrect result when the shift amount is larger than the number of bits available in the underlying T.

The simplest repro is:

Vector128<byte> vector = Vector128.Create(1);
Console.WriteLine(vector << 8);

Where the result should be 1, 1, ..., 1.

The same should be true for Vector128<short> using 16, Vector128<int> using 32, and Vector128<long> using 64.

The shiftAmount in all cases should be functionally vector << (shiftAmount & ((sizeof(T) * 8) - 1))

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions