From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2F077386C5BB; Thu, 30 Jun 2022 08:13:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F077386C5BB From: "luoxhu at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/106069] [12/13 Regression] wrong code with -O -fno-tree-forwprop -maltivec on ppc64le Date: Thu, 30 Jun 2022 08:13:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: luoxhu at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.2 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jun 2022 08:13:49 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106069 --- Comment #4 from luoxhu at gcc dot gnu.org --- Reduced to: #include 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() =3D default; S(unsigned B0) { native_simd_type val{B0}; m_simd =3D val; } void store_le(unsigned char out[]) { store_le_vec.V =3D m_simd; unsigned int x0 =3D store_le_vec.R[0]; memcpy(out, &x0, 1); } static void transpose(S &B0, S B1, S B2, S B3) { native_simd_type T0 =3D __builtin_vec_mergeh(B0.m_simd, B2.m_simd); native_simd_type T1 =3D __builtin_vec_mergeh(B1.m_simd, B3.m_simd); native_simd_type T2 =3D __builtin_vec_mergel(B0.m_simd, B2.m_simd); native_simd_type T3 =3D __builtin_vec_mergel(B1.m_simd, B3.m_simd); B0 =3D __builtin_vec_mergeh(T0, T1); B3 =3D __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 =3D R0; S R01; R01.m_simd =3D R1; S R02; R02.m_simd =3D R2; S R03; R03.m_simd =3D 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 =3D native_simd_type {0x41fcef98, 0,0,0}; native_simd_type R1 =3D native_simd_type {0x91648e8b, 0,0,0}; native_simd_type R2 =3D native_simd_type {0x7dca18c6, 0,0,0}; native_simd_type R3 =3D native_simd_type {0x61707865, 0,0,0}; foo (res, main_state, R0, R1, R2, R3); if (res[0] !=3D 152) __builtin_abort(); }=