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 //simdgen:category Reinterpretation 6 7 package spec 8 9 // ReshapeToUints reinterprets the bits of x as a {z} vector. The least 10 // significant bit of element 0 is bit 0 11 // 12 //specgen:name ReshapeToUint{zN}s 13 //specgen:require xN!=zN 14 func ReshapeToUints[xE Uints, xW Width, zE Uints](x Vec[xE, xW]) (z Vec[zE, xW]) { 15 z = makeVec[zE, xW]() 16 xN, zN := elemBits[xE](), elemBits[zE]() 17 // Copy a byte at a time. 18 for bit := 0; bit < width[xW](); bit += 8 { 19 b := byte(x[bit/xN] >> (bit % xN)) 20 z[bit/zN] |= zE(b) << (bit % zN) 21 } 22 return z 23 } 24