From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 573903858D1E; Fri, 5 Aug 2022 07:22:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 573903858D1E From: "vineetg at rivosinc dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106533] New: loop distribution not distributing inner loop (to memcpy) when perfect loop nest Date: Fri, 05 Aug 2022 07:22:36 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vineetg at rivosinc dot com 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, 05 Aug 2022 07:22:36 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106533 Bug ID: 106533 Summary: loop distribution not distributing inner loop (to memcpy) when perfect loop nest Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vineetg at rivosinc dot com Target Milestone: --- Created attachment 53415 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D53415&action=3Dedit test case When tinkering with a slightly modified version of stream benchmark [1] observed that Loop distribution is not distributing a nested copy loop into= "0 loop and 1 libcall (memcpy)". This is with test built with -O2, mainline gcc, as of June 14, 2022: commit 6abe341558ab Actual test is attached but the loops look like following. Loop 7 (copy) is distributed to memcpy in general case - but not if benchmark built with #de= fine COPYONLY (which elides loops 8,9,10 from compilation). -->8--- for (j=3D0; j<10000000; j++) { // 1 a[j] =3D 1.0; b[j] =3D 2.0; c[j] =3D 0.0; } for (j =3D 0; j < 10000000; j++) // 2 a[j] =3D 2.0E0 * a[j]; for (k=3D0; k<10; k++) // 3 { for (j=3D0; j<10000000; j++) c[j] =3D a[j]; // 7 #ifndef COPYONLY for (j=3D0; j<10000000; j++) b[j] =3D scalar*c[j]; // 8 for (j=3D0; j<10000000; j++) c[j] =3D a[j]+b[j]; // 9 for (j=3D0; j<10000000; j++) a[j] =3D b[j]+scalar*c[j]; // 10 #endif } for (k=3D1; k<10; k++) for (j=3D0; j<4; j++) // 6 avgtime[j] =3D avgtime[j] + times[j][k]; .. for (j=3D0; j<4; j++) // 5 avgtime[j] =3D avgtime[j]/(double)(NTIMES-1); .. -->8---=