> From: Sharma, Dipesh <[email protected]>
> Sent: Tuesday, July 28, 2026 2:47 PM
> 
> > From: Jiang, Haochen <[email protected]>
> > Sent: 28 July 2026 11:35
> >
> > >
> > > diff --git a/gcc/config/i386/avx10v2auxintrin.h
> > > b/gcc/config/i386/avx10v2auxintrin.h
> > > index 3183052b3a3..d67556352cc 100644
> > > --- a/gcc/config/i386/avx10v2auxintrin.h
> > > +++ b/gcc/config/i386/avx10v2auxintrin.h
> > > @@ -587,6 +587,427 @@ _mm512_maskz_cvts_rops_hf8 (__mmask16
> > __U,
> > > __m512 __A)
> > >                                                        (__mmask16) __U);
> > >  }
> > >
> > > +// VCVTBIASPS2BF8 - 128-bit
> > > +
> > > +extern __inline __m128i
> > > +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
> > > +_mm_cvtbiasps_bf8 (__m128i __A, __m128 __B)
> > > +{
> > > +  return (__m128i) __builtin_ia32_vcvtbiasps2bf8128_mask ((__v4si)
> __A,
> >
> > Why are we using SI for FP8 here? I suppose we should use QI.
> It came from SPEC.
> 
> For previous converts (FP16 to FP8), the bias bits were 7-8 only, hence we
> used the QI mode.
> 
> For FP32 to FP8 biased, converts as part of the AVX10V2AUX ISA, the biased
> converts expect a 20 bit bias and hence, I used the next representable form 32
> bit data type(V4SI) for bias.
> We can see if we want to SF over SI for bias type specifically. Let me know 
> your
> thoughts on it.
> 
> 
> <snip from below>
> DEFINE vcvt_ps2f8(src, dst_format, saturation_mode, rounding_mode, VL,
> k1, zeroing,
> no_writemask, src_is_mem, evex_b):
>  // OPND2 encodes the sole source register; no VVVV operand.
> rounding_mode in {"RTNE",
> "RTO"}.
>  // Bias variants (VCVTBIASPS2*) use vcvtbiasps2f8 - separate 3-operand form
> with VVVV.
>  ASSERT VL in (128, 256, 512)
>  KL = VL / 8
>  orig_dest = copy(dest)
>  for i in range(KL / 4):
>  t = src.fp32[0] if (src_is_mem and evex_b) else src.fp32[i]
>  IF k1[i] or no_writemask:
>  IF dst_format == "E5M2":
>  dest.byte[i] = fp32_to_fp8_e5m2(t, saturation_mode, rounding_mode)
>  ELSE:
>  dest.byte[i] = fp32_to_fp8_e4m3(t, saturation_mode, rounding_mode)
>  ELSE IF zeroing:
>  dest.byte[i] = 0
>  ELSE:
>  dest.byte[i] = orig_dest.byte[i]
>  dest[MAXVL-1 : VL/4] = 0
> 
> .
> .
> .
> DEFINE fp32_to_fp8_e4m3(i, saturating, rounding, bias=0):
>  s_i = i[31]
>  e_i = (i >> 23) & 0xFF
>  m_i = i & 0x7FFFFF
> .....
> .....
> ELSE: // BIAS rounding
>  e_b = e_i
>  m_b = m_i + (bias & 0xFFFFF) // 20-bit bias: covers 23→3 bit truncation
>  IF m_b & 0xFF800000:
>  e_b += 1
>  m_b &= 0x7FFFFF
>  newexp = e_b - 127 + 7
>  IF newexp >= 16:
>  e_o = 0xF
>  m_o = 0x6 if saturating else 0x7
>  ELSE IF newexp <= 0:
>  e_o, m_o = 0, 0
>  ELSE:
>  e_o = newexp
>  m_o = m_b >> 20
>  RETURN (s_i & 0x1) << 7 | (e_o & 0xF) << 3 | (m_o & 0x7)
> <snip>
> 

I get your point and from pseudocode, SI usage is correct for now. The
QI is based on a previous version of pseudocode from my side.

Thx,
Haochen

Reply via email to