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

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

https://gcc.gnu.org/g:dfba6b52f5cd44d7bb444085a2b95c9809137c4d

commit r17-5104-gdfba6b52f5cd44d7bb444085a2b95c9809137c4d
Author: Jakub Jelinek <[email protected]>
Date:   Tue Oct 13 08:53:19 2026 +0200

    i386: Enable extendvNhfvNsf2 and truncvNsfvNhf2 for N 4, 8, 16 even for
F16C or AVX512VL [PR121688]

    As the bug report states, we have instructions to implement
    vector _Float16 -> _Float32 and _Float32 -> _Float16 conversions
    not only for AVX512FP16 (in which case we also have direct
    _Float16 <-> _Float64 conversions), but also for F16C and/or
    AVX512F and/or AVX512VL (depending on which exact size,
    F16C or AVX512VL can do vectors of 4 or 8 elements, AVX512F
    can do vectors of 16 elements).
    Unfortunately the RTL for those vector operations is significantly
    different (for non-AVX512FP16 we use UNSPECs and V?HI mode,
    for AVX512FP16 we use float_extend/float_truncate and V?HF mode).

    The following patch arranges for the extendvNhfvNsf2 and truncvNsfvNhf2
    expanders to expand code for the F16C/AVX512F/AVX512VL without
    AVX512FP16 cases.
    I've changed 2 mode iterators (added some conditions to them),
    while they are used not just in these 2 expanders, they are
    used only in TARGET_AVX512FP16 && TARGET_AVX512VL resp.
    TARGET_AVX512FP16 guarded insns, so the condition changes shouldn't
    make a difference there (but if you prefer separate iterators just
    for the 4 define_expands, I can certainly add them instead).

    2026-10-13  Jakub Jelinek  <[email protected]>

            PR target/121688
            * config/i386/sse.md (VF4_128_8_256): Only include
            V4DF if TARGET_AVX512FP16 && TARGET_AVX512VL.
            (VF48H_AVX512VL): Only include V8DF if TARGET_AVX512FP16.
            Include V8SF also if TARGET_F16C && !TARGET_AVX512FP16.
            (extend<ssePHmodelower><mode>2): Change condition
            from TARGET_AVX512FP16 to TARGET_F16C || TARGET_AVX512F.
            Expand !TARGET_AVX512FP16 cases differently.
            (extendv4hf<mode>2): Change condition from
            TARGET_AVX512FP16 && TARGET_AVX512VL to
            TARGET_F16C || TARGET_AVX512VL.  Expand
            !(TARGET_AVX512FP16 && TARGET_AVX512VL) cases differently.
            (trunc<mode><ssePHmodelower>2): Change condition
            from TARGET_AVX512FP16 to TARGET_F16C || TARGET_AVX512F.
            Expand !TARGET_AVX512FP16 cases differently.
            (trunc<mode>v4hf2): Change condition from
            TARGET_AVX512FP16 && TARGET_AVX512VL to
            TARGET_F16C || TARGET_AVX512VL.  Expand
            !(TARGET_AVX512FP16 && TARGET_AVX512VL) cases differently.
            (*vcvtph2ps_load<mask_name>): Rename to ...
            (vcvtph2ps_load<mask_name>): ... this.

            * gcc.target/i386/pr121688-f16c.c: New test.
            * gcc.target/i386/pr121688-avx512f.c: New test.
            * gcc.target/i386/pr121688-avx512fp16.c: New test.
            * gcc.target/i386/pr121688-avx512vl.c: New test.

    Reviewed-by: Hongtao Liu <[email protected]>

Reply via email to