_mm512_mask_range_round_ps
Classification
AVX-512, Miscellaneous, CPUID Test: AVX512DQ
Header File
immintrin.h
Instruction
VRANGEPS zmm {k}, zmm, zmm {sae}, imm8
Synopsis
 _mm512_mask_range_round_ps(__m512 src, __mmask16 k, __m512 a, __m512 b, int imm8, int sae);
Description
Calculate the max, min, absolute max, or absolute min (depending on control in "imm8") for packed single-precision (32-bit) floating-point elements in "a" and "b", and store the results in "dst" using writemask "k" (elements are copied from "src" when the corresponding mask bit is not set). imm8[1:0] specifies the operation control: 00 = min, 01 = max, 10 = absolute max, 11 = absolute min. imm8[3:2] specifies the sign control: 00 = sign from a, 01 = sign from compare result, 10 = clear sign bit, 11 = set sign bit. [sae_note]
Operation
DEFINE RANGE(src1[31:0], src2[31:0], opCtl[1:0], signSelCtl[1:0]) {
	CASE opCtl[1:0] OF
	0: tmp[31:0] := (src1[31:0] <= src2[31:0]) ? src1[31:0] : src2[31:0]
	1: tmp[31:0] := (src1[31:0] <= src2[31:0]) ? src2[31:0] : src1[31:0]
	2: tmp[31:0] := (ABS(src1[31:0]) <= ABS(src2[31:0])) ? src1[31:0] : src2[31:0]
	3: tmp[31:0] := (ABS(src1[31:0]) <= ABS(src2[31:0])) ? src2[31:0] : src1[31:0]
	ESAC
	
	CASE signSelCtl[1:0] OF
	0: dst[31:0] := (src1[31] << 31) OR (tmp[30:0])
	1: dst[31:0] := tmp[63:0]
	2: dst[31:0] := (0 << 31) OR (tmp[30:0])
	3: dst[31:0] := (1 << 31) OR (tmp[30:0])
	ESAC
	
	RETURN dst
}
FOR j := 0 to 15
	i := j*32
	IF k[j]
		dst[i+31:i] := RANGE(a[i+31:i], b[i+31:i], imm8[1:0], imm8[3:2])
	ELSE
		dst[i+31:i] := src[i+31:i]
	FI
ENDFOR
dst[MAX:512] := 0