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

            Bug ID: 113677
           Summary: Missing `VEC_PERM_EXPR <{a, CST}, CST, {0, 1, 2,
                    ...}>` optimization
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
#define vect32 __attribute__((vector_size(4) ))
#define vect64 __attribute__((vector_size(8) ))

vect64 unsigned char f(vect32 unsigned char a)
{
  vect32 unsigned char zero={0,0,0,0};
  return __builtin_shufflevector (a, zero, 0, 1, 2, 3, 4, 5, 6, 7);
}

```
On x86_64 this produces:
```
f:
        movd    xmm0, edi
        pxor    xmm1, xmm1
        punpckldq       xmm0, xmm1
        ret
```

We should just produce:
```
        movd    xmm0, edi
        ret
```

In .optimized we get:
```
  _1 = {a_2(D), { 0, 0, 0, 0 }};
  _3 = VEC_PERM_EXPR <_1, { 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 1, 2, 3, 8, 9, 10,
11 }>;
  return _3;
```


But _3 and _1 are the same ...

Reply via email to