dotnet / dotnet/runtime

AdvSimd shift+widen invalid imm8 range

Open
#122,590 1 comment 0 reactions 0 assignees View on GitHub
area-System.Runtime.Intrinsics
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

### Description

`AdvSimd.ShiftLeftLogicalWideningLower` and friends have the imm argument limited to one too low. For example only 7 when widening bytes. Docs say you should be able to use the full bit width (e.g. 8 on uint8):
https://developer.arm.com/documentation/dui0473/m/neon-instructions/vshll--by-immediate-

### Reproduction Steps

```sharp
AdvSimd.ShiftLeftLogicalWideningLower(Vector64.One, 8)
```

Encountered when trying to widen a byte vector's MSB's to uints.

### Expected behavior

Imm8 range 0..8

### Actual behavior

Imm8 range 0..7, using 8 produces a diagnostic and throws an exception on runtime

### Regression?

-

### Known Workarounds

Widen first, then shift manually (a few extra ops).

### Configuration

.NET 10.0.100
macOS 26.1 (25B78)

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.