_mm_mask_roundscale_ps
Classification
AVX-512, Miscellaneous, CPUID Test: AVX512F
Header File
immintrin.h
Instruction
VRNDSCALEPS xmm {k}, xmm, imm8
Synopsis
 _mm_mask_roundscale_ps(__m128 src, __mmask8 k, __m128 a, int imm8);
Description
Round packed single-precision (32-bit) floating-point elements in "a" to the number of fraction bits specified by "imm8", and store the results in "dst" using writemask "k" (elements are copied from "src" when the corresponding mask bit is not set). [round_imm_note]
Operation
DEFINE RoundScaleFP32(src1[31:0], imm8[7:0]) {
	m[31:0] := FP32(imm8[7:4]) // number of fraction bits after the binary point to be preserved
	tmp[31:0] := POW(FP32(2.0), -m) * ROUND(POW(FP32(2.0), m) * src1[31:0], imm8[3:0])
	IF IsInf(tmp[31:0])
		tmp[31:0] := src1[31:0]
	FI
	RETURN tmp[31:0]
}
FOR j := 0 to 3
	i := j*32
	IF k[j]
		dst[i+31:i] := RoundScaleFP32(a[i+31:i], imm8[7:0])
	ELSE
		dst[i+31:i] := src[i+31:i]
	FI
ENDFOR
dst[MAX:128] := 0