Source file src/simd/internal/spec/reinterp.go
1 // Copyright 2026 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package spec 6 7 // ReshapeToUints reinterprets the bits of x as a {z} vector. The least 8 // significant bit of element 0 is bit 0 9 // 10 //specgen:name ReshapeToUint{zN}s 11 //specgen:require xN!=zN 12 func ReshapeToUints[xE Uints, xW Width, zE Uints](x Vec[xE, xW]) (z Vec[zE, xW]) { 13 z = makeVec[zE, xW]() 14 xN, zN := elemBits[xE](), elemBits[zE]() 15 // Copy a byte at a time. 16 for bit := 0; bit < width[xW](); bit += 8 { 17 b := byte(x[bit/xN] >> (bit % xN)) 18 z[bit/zN] |= zE(b) << (bit % zN) 19 } 20 return z 21 } 22