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

    <tr>
        <th>Summary</th>
        <td>
            Test producing different result after ef38880
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    We have an internal test which started failing recently which I bisected to commit ef38880. Consider the following code:
```c++
#include <stdio.h>
void c(void *d, unsigned e) {
 unsigned char *bytes = (unsigned char *)d;
  char f[3];
  for (unsigned g = 0; g != e; ++g)
    sprintf(f, "%02x", bytes[g]);
 printf(f);
}
typedef int i;
typedef char __attribute__((ext_vector_type(32))) j;
typedef short __attribute__((ext_vector_type(16))) k;
typedef union {
  j a;
  k b;
} l;
typedef struct {
  k a;
} m;
typedef i __attribute__((ext_vector_type(4))) n;
typedef i __attribute__((ext_vector_type(8))) o;
typedef short __attribute__((ext_vector_type(8))) p;
j aa;
n q{3, 60877, 6, 70189285}, r{2, 308336, 5, -17194088},
    s{5, 0, 80290862, 31620660}, ab = r ^ s,
                                 ac{40069418, 5079601, 1, 805389106};
p t;
int main() {
  n u{3058, 7, 4, 4005636};
  q &= ab;
  n v(q | ac);
  o w = __builtin_shufflevector(u, v, 6, 7, 3, 1, 7, 3, 3, 2);
  p x(__builtin_convertvector(w, p));
  k y = __builtin_shufflevector(x, t, 12, 5, 12, 7, 5, 12, 0, 7, 13, 9, 0, 12,
 8, 12, 9, 8);
  l z;
  m ad;
  ad.a = y;
  z.b = ad.a;
  aa = z.a;
  char ae = z.a[8];
  c(&ae, sizeof(z));
}
```
When compiled with optimizations and AVX2 (`-O2 -mavx2`) the program used to print out "04" but after ef38880 now prints "b6" instead.

Link showing the output of trunk for the above program vs. LLVM 16: https://godbolt.org/z/qGozc8aWc
</pre>
<img width="1px" height="1px" alt="" src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