// Code generated by 'tmplgen'; DO NOT EDIT. //go:build goexperiment.simd package archsimd // TruncToInt8 converts each element of x to int8 by discarding its high // bits. // // z[i] = int8(x[i]) // // The results are stored in the low 8 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX func (x Int16x8) TruncToInt8() (z Int8x16) { return x.ToBits().TruncToUint8().BitsToInt8() } // TruncToUint8 converts each element of x to uint8 by discarding its high // bits. // // z[i] = uint8(x[i]) // // The results are stored in the low 8 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX func (x Uint16x8) TruncToUint8() (z Uint8x16) { return x.ReshapeToUint8s().LookupModOrZero(LoadInt8x16Array(&trunc16To8Idx)) } // TruncToInt16 converts each element of x to int16 by discarding its high // bits. // // z[i] = int16(x[i]) // // The results are stored in the low 4 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX func (x Int32x4) TruncToInt16() (z Int16x8) { return x.ToBits().TruncToUint16().BitsToInt16() } // TruncToUint16 converts each element of x to uint16 by discarding its high // bits. // // z[i] = uint16(x[i]) // // The results are stored in the low 4 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX func (x Uint32x4) TruncToUint16() (z Uint16x8) { return x.ReshapeToUint8s().LookupModOrZero(LoadInt8x16Array(&trunc32To16Idx)).ReshapeToUint16s() } // TruncToInt32 converts each element of x to int32 by discarding its high // bits. // // z[i] = int32(x[i]) // // The results are stored in the low 2 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX func (x Int64x2) TruncToInt32() (z Int32x4) { return x.ToBits().TruncToUint32().BitsToInt32() } // TruncToUint32 converts each element of x to uint32 by discarding its high // bits. // // z[i] = uint32(x[i]) // // The results are stored in the low 2 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX func (x Uint64x2) TruncToUint32() (z Uint32x4) { var zero Uint32x4 return x.ReshapeToUint32s().ConcatPermuteScalars(0, 2, 4, 4, zero) } // TruncToInt8 converts each element of x to int8 by discarding its high // bits. // // z[i] = int8(x[i]) // // The results are stored in the low 16 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX2 func (x Int16x16) TruncToInt8() (z Int8x32) { return x.ToBits().TruncToUint8().BitsToInt8() } // TruncToUint8 converts each element of x to uint8 by discarding its high // bits. // // z[i] = uint8(x[i]) // // The results are stored in the low 16 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX2 func (x Uint16x16) TruncToUint8() (z Uint8x32) { if X86.AVX512() { return x.truncToUint8() } g := x.ReshapeToUint8s().LookupModOrZeroGrouped(LoadInt8x32Array(&trunc16To8GroupedIdx)) return gatherLo64(g.ReshapeToUint64s()).ReshapeToUint8s() } // TruncToInt16 converts each element of x to int16 by discarding its high // bits. // // z[i] = int16(x[i]) // // The results are stored in the low 8 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX2 func (x Int32x8) TruncToInt16() (z Int16x16) { return x.ToBits().TruncToUint16().BitsToInt16() } // TruncToUint16 converts each element of x to uint16 by discarding its high // bits. // // z[i] = uint16(x[i]) // // The results are stored in the low 8 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX2 func (x Uint32x8) TruncToUint16() (z Uint16x16) { if X86.AVX512() { return x.truncToUint16() } g := x.ReshapeToUint8s().LookupModOrZeroGrouped(LoadInt8x32Array(&trunc32To16GroupedIdx)) return gatherLo64(g.ReshapeToUint64s()).ReshapeToUint16s() } // TruncToInt32 converts each element of x to int32 by discarding its high // bits. // // z[i] = int32(x[i]) // // The results are stored in the low 4 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX2 func (x Int64x4) TruncToInt32() (z Int32x8) { return x.ToBits().TruncToUint32().BitsToInt32() } // TruncToUint32 converts each element of x to uint32 by discarding its high // bits. // // z[i] = uint32(x[i]) // // The results are stored in the low 4 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX2 func (x Uint64x4) TruncToUint32() (z Uint32x8) { if X86.AVX512() { return x.truncToUint32() } var zero Uint32x8 g := x.ReshapeToUint32s().ConcatPermuteScalarsGrouped(0, 2, 4, 4, zero) return gatherLo64(g.ReshapeToUint64s()).ReshapeToUint32s() } // SaturateToInt8 converts each element of x to int8, saturating values // that are outside the range of int8. // // z[i] = sat(x[i]) // // The results are stored in the low 8 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX func (x Int16x8) SaturateToInt8() (z Int8x16) { var zero Int16x8 return x.concatSaturateToInt8(zero) } // SaturateToUint8 converts each element of x to uint8, saturating values // that are outside the range of uint8. Negative values become 0. // // z[i] = sat(x[i]) // // The results are stored in the low 8 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX func (x Int16x8) SaturateToUint8() (z Uint8x16) { var zero Int16x8 return x.concatSaturateToUint8(zero) } // SaturateToUint8 converts each element of x to uint8, saturating values // that are outside the range of uint8. // // z[i] = sat(x[i]) // // The results are stored in the low 8 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX func (x Uint16x8) SaturateToUint8() (z Uint8x16) { if X86.AVX512() { return x.saturateToUint8() } // After the Min, x is non-negative as an int16, so the signed-to-unsigned // saturation doesn't change it. x = x.Min(LoadUint16x8Array(&maxUint8x8)) return x.BitsToInt16().SaturateToUint8() } // SaturateToInt16 converts each element of x to int16, saturating values // that are outside the range of int16. // // z[i] = sat(x[i]) // // The results are stored in the low 4 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX func (x Int32x4) SaturateToInt16() (z Int16x8) { var zero Int32x4 return x.ConcatSaturateToInt16(zero) } // SaturateToUint16 converts each element of x to uint16, saturating values // that are outside the range of uint16. Negative values become 0. // // z[i] = sat(x[i]) // // The results are stored in the low 4 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX func (x Int32x4) SaturateToUint16() (z Uint16x8) { var zero Int32x4 return x.ConcatSaturateToUint16(zero) } // SaturateToUint16 converts each element of x to uint16, saturating values // that are outside the range of uint16. // // z[i] = sat(x[i]) // // The results are stored in the low 4 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX func (x Uint32x4) SaturateToUint16() (z Uint16x8) { if X86.AVX512() { return x.saturateToUint16() } // After the Min, x is non-negative as an int32, so the signed-to-unsigned // saturation doesn't change it. x = x.Min(LoadUint32x4Array(&maxUint16x4)) return x.BitsToInt32().SaturateToUint16() } // SaturateToInt32 converts each element of x to int32, saturating values // that are outside the range of int32. // // z[i] = sat(x[i]) // // The results are stored in the low 2 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX func (x Int64x2) SaturateToInt32() (z Int32x4) { if X86.AVX512() { return x.saturateToInt32() } hi, lo := LoadInt64x2Array(&maxInt32x2), LoadInt64x2Array(&minInt32x2) x = hi.IfElse(x.Greater(hi), x) x = lo.IfElse(x.Less(lo), x) return x.TruncToInt32() } // SaturateToUint32 converts each element of x to uint32, saturating values // that are outside the range of uint32. Negative values become 0. // // z[i] = sat(x[i]) // // The results are stored in the low 2 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX func (x Int64x2) SaturateToUint32() (z Uint32x4) { var zero Int64x2 if X86.AVX512() { return x.Max(zero).ToBits().saturateToUint32() } hi := LoadInt64x2Array(&maxUint32x2) x = x.Masked(x.Greater(zero)) x = hi.IfElse(x.Greater(hi), x) return x.ToBits().TruncToUint32() } // SaturateToUint32 converts each element of x to uint32, saturating values // that are outside the range of uint32. // // z[i] = sat(x[i]) // // The results are stored in the low 2 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX func (x Uint64x2) SaturateToUint32() (z Uint32x4) { if X86.AVX512() { return x.saturateToUint32() } // x fits in a uint32 if its high 32 bits are zero. var zero Uint64x2 hi := LoadInt64x2Array(&maxUint32x2).ToBits() return x.IfElse(x.ShiftAllRight(32).Equal(zero), hi).TruncToUint32() } // SaturateToInt8 converts each element of x to int8, saturating values // that are outside the range of int8. // // z[i] = sat(x[i]) // // The results are stored in the low 16 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX2 func (x Int16x16) SaturateToInt8() (z Int8x32) { if X86.AVX512() { return x.saturateToInt8() } var zero Int16x16 g := x.concatSaturateToInt8Grouped(zero) return gatherLo64(g.ToBits().ReshapeToUint64s()).ReshapeToUint8s().BitsToInt8() } // SaturateToUint8 converts each element of x to uint8, saturating values // that are outside the range of uint8. Negative values become 0. // // z[i] = sat(x[i]) // // The results are stored in the low 16 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX2 func (x Int16x16) SaturateToUint8() (z Uint8x32) { var zero Int16x16 g := x.concatSaturateToUint8Grouped(zero) return gatherLo64(g.ReshapeToUint64s()).ReshapeToUint8s() } // SaturateToUint8 converts each element of x to uint8, saturating values // that are outside the range of uint8. // // z[i] = sat(x[i]) // // The results are stored in the low 16 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX2 func (x Uint16x16) SaturateToUint8() (z Uint8x32) { if X86.AVX512() { return x.saturateToUint8() } // After the Min, x is non-negative as an int16, so the signed-to-unsigned // saturation doesn't change it. x = x.Min(LoadUint16x16Array(&maxUint8x16)) return x.BitsToInt16().SaturateToUint8() } // SaturateToInt16 converts each element of x to int16, saturating values // that are outside the range of int16. // // z[i] = sat(x[i]) // // The results are stored in the low 8 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX2 func (x Int32x8) SaturateToInt16() (z Int16x16) { if X86.AVX512() { return x.saturateToInt16() } var zero Int32x8 g := x.ConcatSaturateToInt16Grouped(zero) return gatherLo64(g.ToBits().ReshapeToUint64s()).ReshapeToUint16s().BitsToInt16() } // SaturateToUint16 converts each element of x to uint16, saturating values // that are outside the range of uint16. Negative values become 0. // // z[i] = sat(x[i]) // // The results are stored in the low 8 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX2 func (x Int32x8) SaturateToUint16() (z Uint16x16) { var zero Int32x8 g := x.ConcatSaturateToUint16Grouped(zero) return gatherLo64(g.ReshapeToUint64s()).ReshapeToUint16s() } // SaturateToUint16 converts each element of x to uint16, saturating values // that are outside the range of uint16. // // z[i] = sat(x[i]) // // The results are stored in the low 8 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX2 func (x Uint32x8) SaturateToUint16() (z Uint16x16) { if X86.AVX512() { return x.saturateToUint16() } // After the Min, x is non-negative as an int32, so the signed-to-unsigned // saturation doesn't change it. x = x.Min(LoadUint32x8Array(&maxUint16x8)) return x.BitsToInt32().SaturateToUint16() } // SaturateToInt32 converts each element of x to int32, saturating values // that are outside the range of int32. // // z[i] = sat(x[i]) // // The results are stored in the low 4 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX2 func (x Int64x4) SaturateToInt32() (z Int32x8) { if X86.AVX512() { return x.saturateToInt32() } hi, lo := LoadInt64x4Array(&maxInt32x4), LoadInt64x4Array(&minInt32x4) x = hi.IfElse(x.Greater(hi), x) x = lo.IfElse(x.Less(lo), x) return x.TruncToInt32() } // SaturateToUint32 converts each element of x to uint32, saturating values // that are outside the range of uint32. Negative values become 0. // // z[i] = sat(x[i]) // // The results are stored in the low 4 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX2 func (x Int64x4) SaturateToUint32() (z Uint32x8) { var zero Int64x4 if X86.AVX512() { return x.Max(zero).ToBits().saturateToUint32() } hi := LoadInt64x4Array(&maxUint32x4) x = x.Masked(x.Greater(zero)) x = hi.IfElse(x.Greater(hi), x) return x.ToBits().TruncToUint32() } // SaturateToUint32 converts each element of x to uint32, saturating values // that are outside the range of uint32. // // z[i] = sat(x[i]) // // The results are stored in the low 4 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX2 func (x Uint64x4) SaturateToUint32() (z Uint32x8) { if X86.AVX512() { return x.saturateToUint32() } // x fits in a uint32 if its high 32 bits are zero. var zero Uint64x4 hi := LoadInt64x4Array(&maxUint32x4).ToBits() return x.IfElse(x.ShiftAllRight(32).Equal(zero), hi).TruncToUint32() } // SaturateToUint8 converts each element of x to uint8, saturating values // that are outside the range of uint8. Negative values become 0. // // z[i] = sat(x[i]) // // The results are stored in the low 32 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX512 func (x Int16x32) SaturateToUint8() (z Uint8x64) { var zero Int16x32 return x.Max(zero).ToBits().SaturateToUint8() } // SaturateToUint8 converts each element of x to uint8, saturating values // that are outside the range of uint8. Negative values become 0. // // z[i] = sat(x[i]) // // The results are stored in the low 4 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX512 func (x Int32x4) SaturateToUint8() (z Uint8x16) { var zero Int32x4 return x.Max(zero).ToBits().SaturateToUint8() } // SaturateToUint8 converts each element of x to uint8, saturating values // that are outside the range of uint8. Negative values become 0. // // z[i] = sat(x[i]) // // The results are stored in the low 8 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX512 func (x Int32x8) SaturateToUint8() (z Uint8x32) { var zero Int32x8 return x.Max(zero).ToBits().SaturateToUint8() } // SaturateToUint8 converts each element of x to uint8, saturating values // that are outside the range of uint8. Negative values become 0. // // z[i] = sat(x[i]) // // The results are stored in the low 16 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX512 func (x Int32x16) SaturateToUint8() (z Uint8x64) { var zero Int32x16 return x.Max(zero).ToBits().SaturateToUint8() } // SaturateToUint8 converts each element of x to uint8, saturating values // that are outside the range of uint8. Negative values become 0. // // z[i] = sat(x[i]) // // The results are stored in the low 2 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX512 func (x Int64x2) SaturateToUint8() (z Uint8x16) { var zero Int64x2 return x.Max(zero).ToBits().SaturateToUint8() } // SaturateToUint8 converts each element of x to uint8, saturating values // that are outside the range of uint8. Negative values become 0. // // z[i] = sat(x[i]) // // The results are stored in the low 4 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX512 func (x Int64x4) SaturateToUint8() (z Uint8x32) { var zero Int64x4 return x.Max(zero).ToBits().SaturateToUint8() } // SaturateToUint8 converts each element of x to uint8, saturating values // that are outside the range of uint8. Negative values become 0. // // z[i] = sat(x[i]) // // The results are stored in the low 8 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX512 func (x Int64x8) SaturateToUint8() (z Uint8x64) { var zero Int64x8 return x.Max(zero).ToBits().SaturateToUint8() } // SaturateToUint16 converts each element of x to uint16, saturating values // that are outside the range of uint16. Negative values become 0. // // z[i] = sat(x[i]) // // The results are stored in the low 16 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX512 func (x Int32x16) SaturateToUint16() (z Uint16x32) { var zero Int32x16 return x.Max(zero).ToBits().SaturateToUint16() } // SaturateToUint16 converts each element of x to uint16, saturating values // that are outside the range of uint16. Negative values become 0. // // z[i] = sat(x[i]) // // The results are stored in the low 2 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX512 func (x Int64x2) SaturateToUint16() (z Uint16x8) { var zero Int64x2 return x.Max(zero).ToBits().SaturateToUint16() } // SaturateToUint16 converts each element of x to uint16, saturating values // that are outside the range of uint16. Negative values become 0. // // z[i] = sat(x[i]) // // The results are stored in the low 4 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX512 func (x Int64x4) SaturateToUint16() (z Uint16x16) { var zero Int64x4 return x.Max(zero).ToBits().SaturateToUint16() } // SaturateToUint16 converts each element of x to uint16, saturating values // that are outside the range of uint16. Negative values become 0. // // z[i] = sat(x[i]) // // The results are stored in the low 8 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX512 func (x Int64x8) SaturateToUint16() (z Uint16x32) { var zero Int64x8 return x.Max(zero).ToBits().SaturateToUint16() } // SaturateToUint32 converts each element of x to uint32, saturating values // that are outside the range of uint32. Negative values become 0. // // z[i] = sat(x[i]) // // The results are stored in the low 8 elements of z. // The remaining elements of z are zero. // // Emulated, CPU Feature: AVX512 func (x Int64x8) SaturateToUint32() (z Uint32x16) { var zero Int64x8 return x.Max(zero).ToBits().SaturateToUint32() }