<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/54646>54646</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Missed optimization - over-strict alias analysis?
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          OfekShilon
      </td>
    </tr>
</table>

<pre>
    This code:
```cpp
struct S { long int a; long int b; };
void f(S& s3, const S& s4 ) {
    s3.a = s4.a;
    s3.b = s4.b;
}
```
optimizes well into vectorized assembly:
```
        movups  xmm0, xmmword ptr [rsi]
        movups  xmmword ptr [rdi], xmm0
```
Surprisingly, wrapping the primitive `long int`s in structs seems to prevent optimizations due to aliasing concerns. This:
```cpp
struct Wrapper { long int t; };
struct S1 { Wrapper a; Wrapper b; };

void f(S1& s1, const S1& s2 ) {
    s1.a = s2.a;
    s1.b = s2.b;
}
```
produces suboptimal assembly:
```
        movq    (%rsi), %rax
        movq    %rax, (%rdi)
        movq    8(%rsi), %rax
        movq    %rax, 8(%rdi)
```
And an optimization-remark, produced by the gvn pass - typically on suspected aliasing:

>  load of type i64 not eliminated because it is clobbered by store

There was no aliasing detected on the un-wrapped source, it seems certainly there shouldn't be one on the wrapped source.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydVE1v2zAM_TXKhUhgy3E-Dj60y3obdkiBnWWLjrXKlifJSbNfP0qO1yZtsY8giEKRfHyiHlUaeS4eG-WgMhJZdseSHUvu2CoZv1XfjzvO26HysAe2vgdtugOozoNg2SurDBZb72gZk45GSagZ3-wZX4HLGP9EdTpHOHFjCYxvA-IYDvRx2UIAy3bkXIjfQBdPOXnK355Q7pryaJreq1b9RAcn1DrQM3DEyhtLmxKEc9iW-vz2xC8Fw6c1x6F3AM9tmwT2tJ6MldB7Cyy_t06xfPdhylWojKEjRvJu0f1ge6uc6g5EjAJPVvQ9WeAbBPK0yqsjAsVPLae_jlYYb8eBQ2wd0FF7i0ekK7m0QXhFbQc5YHAKrUSoEu6iQtu5BQQJ_Pn2vwVCaK814G9vfZJKGuOmnCiVyXijlFu9pFEf6SvBjDv8HcWkk2L4rWLSSTH8LxTTWyOHigTjhjK2Teh_kcmPsBJ1xvOgCr4N3IMhnj-Kjb4YFbNkzHo3dvN_wJu3yDcHuOtoFrormcwttsI-hfxLSySU56jBw7GDnnoCc_DnXlVC6zMYkt_gepqtMFcXab00bPzNPgMpRkgwdUhFUKsldMYDairciZBbYiUGRy4P4T3SpizRjsUdzS2-BnxsyAUn4QjkRc8S_UiDOAW-QzePM0Q7zgy2wnAogh_HhKTvhep0PBuhucYMWnaMr-kpQ8LACecaZDFSmMkik9tsK2ZeeY3FF0VikVetpD6ZI9o5TYSiiYg8qd1Cn10Yt4fZYHXReN_H2eMP9D0o3wzlojItGVofp2VOd_GdDkcm1RnQ0Z98uVquZk2R1xLzCjf5kpecJ1XK1-kyxVrIbMvTajvTokTtCnqF6AmaqYInFJZlSZpneZos0roSy3q1komUdZKv2DIhCSi9CIUXxh5mtogcyuHgyKmV8-7FSYJQhw5xwheDb4wtvtb4tG8UvROzyLiIdH8BjjTrAQ">