[Bug target/106069] [12/13 Regression] wrong code with -O -fno-tree-forwprop -maltivec on ppc64le
luoxhu at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jun 30 08:13:48 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106069
--- Comment #4 from luoxhu at gcc dot gnu.org ---
Reduced to:
#include <stdio.h>
extern "C" void *memcpy(void *, const void *, unsigned long);
typedef __attribute__((altivec(vector__))) unsigned native_simd_type;
union {
native_simd_type V;
int R[4];
} store_le_vec;
struct S {
S() = default;
S(unsigned B0) {
native_simd_type val{B0};
m_simd = val;
}
void store_le(unsigned char out[]) {
store_le_vec.V = m_simd;
unsigned int x0 = store_le_vec.R[0];
memcpy(out, &x0, 1);
}
static void transpose(S &B0, S B1, S B2, S B3) {
native_simd_type T0 = __builtin_vec_mergeh(B0.m_simd,
B2.m_simd);
native_simd_type T1 = __builtin_vec_mergeh(B1.m_simd,
B3.m_simd);
native_simd_type T2 = __builtin_vec_mergel(B0.m_simd,
B2.m_simd);
native_simd_type T3 = __builtin_vec_mergel(B1.m_simd,
B3.m_simd);
B0 = __builtin_vec_mergeh(T0, T1);
B3 = __builtin_vec_mergel(T2, T3);
printf ("B0: %x, %x,%x,%x\n", B0.m_simd[0], B0.m_simd[1],
B0.m_simd[2], B0.m_simd[3]);
}
S(native_simd_type x) : m_simd(x) {}
native_simd_type m_simd;
};
void
foo (unsigned char output[], unsigned state[], native_simd_type R0,
native_simd_type R1, native_simd_type R2, native_simd_type R3)
{
S R00; R00.m_simd = R0;
S R01; R01.m_simd = R1;
S R02; R02.m_simd = R2;
S R03; R03.m_simd = R3;
S::transpose(R00, R01, R02, R03);
R00.store_le(output);
}
unsigned char res[1];
unsigned main_state[]{1634760805, 60878, 2036477234, 6,
0, 825562964, 1471091955, 1346092787,
506976774, 4197066702, 518848283, 118491664,
0, 0, 0, 0};
int
main ()
{
native_simd_type R0 = native_simd_type {0x41fcef98, 0,0,0};
native_simd_type R1 = native_simd_type {0x91648e8b, 0,0,0};
native_simd_type R2 = native_simd_type {0x7dca18c6, 0,0,0};
native_simd_type R3 = native_simd_type {0x61707865, 0,0,0};
foo (res, main_state, R0, R1, R2, R3);
if (res[0] != 152)
__builtin_abort();
}
More information about the Gcc-bugs
mailing list