On Thu, Jun 26, 2025 at 2:11 PM Hongtao Liu <crazy...@gmail.com> wrote:
>
> On Thu, Jun 26, 2025 at 1:59 PM H.J. Lu <hjl.to...@gmail.com> wrote:
> >
> > Use the inner scalar mode of vector broadcast source in:
> >
> >   (set (reg:V8DF 394)
> >        (vec_duplicate:V8DF (reg:V2DF 190 [ alpha ])))
> >
> > to compute the vector mode for broadcast from vector source.
>
>  ix86_get_vector_cse_mode (unsigned int size, machine_mode smode)
>  {
> +  /* Use the inner scalar mode of vector broadcast source in:
> +
> +     (set (reg:V8DF 394)
> +   (vec_duplicate:V8DF (reg:V2DF 190 [ alpha ])))
> +
> +     to compute the vector mode for broadcast from vector source.
> +   */
> +  if (VECTOR_MODE_P (smode))
> +    smode = GET_MODE_INNER (smode);
>
> I think we need to figure out why vector mode is passed to
> ix86_get_vector_cse_mode and fix there.

There is nothing wrong with V2DF passed to ix86_get_vector_cse_mode.
The testcase shows that there are

(insn 14 12 40 3 (set (reg:V8DF 99 [ _11 ])
        (vec_duplicate:V8DF (reg:V2DF 102 [ pretmp_22 ])))
"x.cc":68:64 9289 {*avx512dq_broadcastv8df_1}
     (expr_list:REG_DEAD (reg:V2DF 102 [ pretmp_22 ])
        (nil)))
...
(insn 28 26 30 5 (set (reg:V8DF 109)
        (vec_duplicate:V8DF (reg:V2DF 102 [ pretmp_22 ])))
"x.cc":68:64 9289 {*avx512dq_broadcastv8df_1}
     (expr_list:REG_DEAD (reg:V2DF 102 [ pretmp_22 ])
        (nil)))

We add

(insn 44 9 10 2 (set (reg:V8DF 116)
        (vec_duplicate:V8DF (reg:V2DF 102 [ pretmp_22 ]))) "x.cc":44:10 -1
     (nil))

after:

(insn 9 8 44 2 (set (reg:V2DF 102 [ pretmp_22 ])
        (mem/j:V2DF (plus:DI (reg/f:DI 19 frame)
                (const_int -20 [0xffffffffffffffec])) [3 +0 S16 A32]))
"x.cc":44:10 2429 {movv2df_internal}
     (nil))

to eliminate the redundant V2DF -> V8DF broadcast.

> >
> > gcc/
> >
> > PR target/120830
> > * config/i386/i386-features.cc (ix86_get_vector_cse_mode): Handle
> > vector broadcast source.
> >
> > gcc/testsuite/
> >
> > PR target/120830
> > * g++.target/i386/pr120830.C: New test.
> >
> > OK for master?
> >
> > --
> > H.J.
>
>
>
> --
> BR,
> Hongtao



-- 
H.J.

Reply via email to