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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
          Component|target                      |tree-optimization
   Last reconfirmed|                            |2024-07-24
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot 
gnu.org
             Status|UNCONFIRMED                 |ASSIGNED
             Target|aarch64                     |aarch64 riscv
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>   _72 = .VEC_SHL_INSERT ({ 0, ... }, 0);

Confirmed.
This could be optimized at the gimple level to just `{0, ...}` I think.

And it shows up in RISCV too:
```
        vsetvli a4,zero,e32,m1,ta,ma
        vmv.v.i v2,0
        csrr    a3,vlenb
        li      a0,32768
        srli    a3,a3,2
        addi    a0,a0,-768
        lui     a5,%hi(in)
        vslide1up.vx    v1,v2,zero
```

The internal function is a direct function to the optab vec_shl_insert:

```
@cindex @code{vec_shl_insert_@var{m}} instruction pattern
@item @samp{vec_shl_insert_@var{m}}
Shift the elements in vector input operand 1 left one element (i.e.@:
away from element 0) and fill the vacated element 0 with the scalar
in operand 2.  Store the result in vector output operand 0.  Operands
0 and 1 have mode @var{m} and operand 2 has the mode appropriate for
one element of @var{m}.
```

So if we have 0 for both then the result is also 0.

So this should fold it:
```
(simplify
 (INF_VEC_SHL_INSERT @1 uniform_vector_p@2)
 (if (operands_equal (@1, uniform_vector_p(@2))
  @2))

```

That is if we are inserting a value that is the same as the uniform vector we
can just simplify it to the uniform vector.

I will take care of this.

Reply via email to