From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5C2443851C0B; Tue, 5 Jan 2021 16:17:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C2443851C0B From: "rsandifo at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/98542] New: Redundant loads in vectorised loop Date: Tue, 05 Jan 2021 16:17:03 +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.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rsandifo 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: Tue, 05 Jan 2021 16:17:03 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98542 Bug ID: 98542 Summary: Redundant loads in vectorised loop Product: gcc Version: 11.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rsandifo at gcc dot gnu.org Target Milestone: --- For the testcase below, based loosely on one from 450.soplex, the vectoriser loads the v and i fields twice: struct s { double v; long i; }; double f (struct s *x, double *y, int n) { double res =3D 0; for (int i =3D 0; i < n; ++i) res +=3D x[i].v * y[x[i].i]; return res; } SVE loop: add x5, x0, 8 ... .L4: ld2d {z2.d - z3.d}, p0/z, [x5, x4, lsl 3] ld2d {z4.d - z5.d}, p0/z, [x0, x4, lsl 3] ld1d z2.d, p0/z, [x1, z2.d, lsl 3] incd x3 fmla z0.d, p0/m, z4.d, z2.d incw x4 whilelo p0.d, w3, w2 b.any .L4 where z5 from the second ld2d is the same as z2 from the first ld2d. In the soplex example, "i" is instead a 32-bit value, but I guess we need to fix this case first.=