-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Description
We have an internal test which started failing recently which I bisected to commit ef38880. Consider the following code:
#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