From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 201E9385840A; Wed, 6 Jul 2022 18:19:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 201E9385840A From: "tnfchris at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106217] New: [11/12/13 Regression] sinking of loads prevents vectorization Date: Wed, 06 Jul 2022 18:19:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.3.1 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: tnfchris 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 keywords bug_severity priority component assigned_to reporter target_milestone 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: Wed, 06 Jul 2022 18:19:34 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106217 Bug ID: 106217 Summary: [11/12/13 Regression] sinking of loads prevents vectorization Product: gcc Version: 11.3.1 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: tnfchris at gcc dot gnu.org Target Milestone: --- The following example void f(int n, float * __restrict x, float *mass, float max, float &ax) { float lax =3D 0.0f; for (int i =3D 0; i < n; ++i) { float f =3D x[i] * mass[i]; lax +=3D x[i] >=3D max ? 0 : f * x[i]; } ax +=3D lax; return; } vectorizes with GCC 10 with -Ofast but fails starting with GCC 11. The difference is that in the sink1 pass we now sink the unconditional load= of mass[i] into the conditional. Sinking # VUSE <.MEM_14(D)> _7 =3D *_6; from bb 3 to bb 4 Sinking _6 =3D mass_18(D) + _2; from bb 3 to bb 4 consequently this causes if-convert to no longer be able to if-convert the = loop because the load is now conditional, and we only accept unconditional loads= in ifcvt_memrefs_wont_trap. ------------------------- _6 =3D mass_18(D) + _2; ------------------------- _7 =3D *_6; tree could trap... perhaps during the sinking we should mark the load as non-trapping? as it w= as originally unconditional anyway.=