Skip to content

SIMD.js: Shift amounts greater than lane width's causes simd lanes to be zeroed #773

@arunetm-zz

Description

@arunetm-zz

Shift operations can cause SIMD lanes to be zeroed when the shift amounts are set to be greater than the lane element widths. As per the latest spec shift amounts for simd types needs to be masked to be within the lane width.

Repro Case

var v = SIMD.Int8x16(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4);
var res = SIMD.Int8x16.shiftLeftByScalar(v, 9);
print(res);
res = SIMD.Int8x16.shiftRightByScalar(v, 9);
print(res);

Actual Result

SIMD.Int8x16(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
SIMD.Int8x16(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

Expected Result

SIMD.Int8x16(2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8, 2, 4, 6, 8)
SIMD.Int8x16(0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions