From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E8E1F3858C35; Tue, 13 Feb 2024 12:36:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E8E1F3858C35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707827767; bh=RwnCon9YLAN4/5ChYC+CYyw6E+lHX5xWvl2kNY7uQKc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=m2vNmjUVxhqk/P1/7mzT68pJVly8r/vAVBVQ6X6J7RyOAsBuKEu04TsQK3UEDx/19 VPd9veP6Y5F4JjYKKGKkBD2/AVBVz4RQGj3zxEpUyrZoQJ7KYJoI3DP9L5eGXj3pQB dpHSXgZi33+kukSyAWZJrEmyWp0X/Nijr6oExj9I= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113896] [12 Regression] Assigning array elements in the wrong order after floating point optimization since r12-8841 Date: Tue, 13 Feb 2024 12:36:06 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.3.1 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.4 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113896 --- Comment #4 from Richard Biener --- I have a bit of a deja-vu here. The SLP permute optimization phase was rewritten for GCC 13, the following fixes the latent issue for GCC 12: diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index af477c31aa3..b3e3d9e7009 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -4058,6 +4058,15 @@ vect_optimize_slp (vec_info *vinfo) { /* Preserve the special VEC_PERM we use to shield existing vector defs from the rest. But make it a no-op. */ + auto_vec saved; + saved.create (SLP_TREE_SCALAR_STMTS (old).length ()); + for (unsigned i =3D 0; + i < SLP_TREE_SCALAR_STMTS (old).length (); ++i) + saved.quick_push (SLP_TREE_SCALAR_STMTS (old)[i]); + for (unsigned i =3D 0; + i < SLP_TREE_SCALAR_STMTS (old).length (); ++i) + SLP_TREE_SCALAR_STMTS (old)[i] + =3D saved[SLP_TREE_LANE_PERMUTATION (old)[i].second]; unsigned i =3D 0; for (std::pair &p : SLP_TREE_LANE_PERMUTATION (old))=