From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A91343858D3C; Fri, 11 Mar 2022 14:18:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A91343858D3C From: "acoplan at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/104882] New: [12 Regression] MVE: Wrong code at -O2 since r12-1434-g046a3beb1673bf4a61c131373b6a5e84158e92bf Date: Fri, 11 Mar 2022 14:18:38 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: acoplan 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: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: 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: Fri, 11 Mar 2022 14:18:38 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104882 Bug ID: 104882 Summary: [12 Regression] MVE: Wrong code at -O2 since r12-1434-g046a3beb1673bf4a61c131373b6a5e84158e92bf Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: acoplan at gcc dot gnu.org Target Milestone: --- Created attachment 52608 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D52608&action=3Dedit broken assembly output The following code: int i; char src[1072]; char dst[72]; int main() { for (i =3D 0; i < 128; i++) src[i] =3D i; __builtin_memcpy(dst, src, 7); for (i =3D 0; i < 7; i++) if (dst[i] !=3D i) __builtin_abort(); } is miscompiled at -O2 since vectorization was enabled at -O2. With -O2 -ftree-vectorize, it is miscompiled earlier, starting with: commit 046a3beb1673bf4a61c131373b6a5e84158e92bf Author: Christophe Lyon Date: Thu Jun 3 15:35:50 2021 arm: Auto-vectorization for MVE: add pack/unpack patterns It looks like we do some dubious packing of vector elements before storing = to src. If I change the last loop to print the elements of dst instead, I see: 0 8 4 12 1 9 5 it should of course print: 0 1 2 3 4 5 6. The broken code is attached. The testcase above was reduced from gcc/testsuite/gcc.c-torture/execute/memcpy-1.c.=