https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122382

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Uros Bizjak <[email protected]>:

https://gcc.gnu.org/g:373c7598a996ff568c831a653bc25292691125b1

commit r17-5729-g373c7598a996ff568c831a653bc25292691125b1
Author: Uros Bizjak <[email protected]>
Date:   Wed Oct 28 10:10:34 2026 +0100

    i386: Vectorize _Float16 <-> float conversions with F16C and AVX512F
[PR122382]

    The vectorizer converts between float and _Float16 vectors of different
    lane counts through the vec_pack_trunc and vec_unpacks_{lo,hi} optabs.
    These were only provided for TARGET_AVX512FP16, so for x86-64-v3 (F16C)
    and for AVX512F-only targets the conversion loops stayed scalar, even
    though vcvtps2ph and vcvtph2ps can do the work.

    Enable the pack and unpack expanders for all the float and _Float16
    vector modes they already handle, using new mode iterators:

      - V16SF/V32HF with AVX512F,
      - V8SF/V4SF and V16HF/V8HF with F16C or AVX512VL.

    The 256- and 512-bit modes reuse the same-lane trunc<mode><ssePHmodelower>2
    and extend<ssePHmodelower><mode>2 expanders, which already fall back to
    vcvtps2ph/vcvtph2ps without AVX512FP16.  The 128-bit modes needed two
    changes:

      - Add f16c_truncv4sfv8hf2, which emits the V8HF result directly.  It
        uses the AVX512FP16 insn when available and vcvtps2ph otherwise.
        vec_pack_trunc_v4sf uses it instead of the AVX512FP16-only insn, and
        trunc<mode>v4hf2 is rewritten on top of it.
      - Unpack V8HF through extendv4hfv4sf2 instead of calling the
        AVX512FP16-only avx512fp16_float_extend_phv4sf2 directly.

    Targets with AVX512FP16 continue to use the direct vcvtps2phx and
    vcvtph2psx forms (the 128- and 256-bit ones also need AVX512VL).

    The compile tests check that the loops vectorize and that no scalar
    vpinsrw/vpextrw remain, for F16C, for AVX512VL without F16C, and for
    AVX512F alone.  The run tests compare the vectorized conversions,
    including lane order and epilogues, against scalar reference loops.

    Assisted-by: Claude Sonnet 5.5

            PR target/122382

    gcc/ChangeLog:

            * config/i386/sse.md (VHF_F16C, VF1_F16C): New mode iterators.
            (vec_unpacks_lo_<mode>, vec_unpacks_hi_<mode>): Use VHF_F16C.
            Remove the TARGET_AVX512FP16 condition.  Call gen_extendv4hfv4sf2
            for V8HFmode.
            (f16c_truncv4sfv8hf2): New expander.
            (trunc<mode>v4hf2): Use it for V4SFmode.
            (vec_pack_trunc_<mode>): Use VF1_F16C.  Remove the
            TARGET_AVX512FP16 condition.  Call gen_f16c_truncv4sfv8hf2 for
            V4SFmode.

    gcc/testsuite/ChangeLog:

            * gcc.target/i386/pr122382.c: New test.
            * gcc.target/i386/pr122382-1.c: Likewise.
            * gcc.target/i386/pr122382-1a.c: Likewise.
            * gcc.target/i386/pr122382-2.c: Likewise.
            * gcc.target/i386/pr122382-2a.c: Likewise.
            * gcc.target/i386/pr122382-3.c: Likewise.
            * gcc.target/i386/pr122382-4.c: Likewise.
            * gcc.target/i386/pr122382-5.c: Likewise.
            * gcc.target/i386/pr122382-6.c: Likewise.
            * gcc.target/i386/pr122382.h: New file.

Reply via email to