From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7C2ED3858D37; Fri, 5 Aug 2022 07:32:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7C2ED3858D37 From: "vineetg at rivosinc dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106533] loop distribution not distributing inner loop (to memcpy) when perfect loop nest Date: Fri, 05 Aug 2022 07:32:27 +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: 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: cc 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 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:32:27 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106533 Vineet Gupta changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |vineetg at rivosinc dot com --- Comment #1 from Vineet Gupta --- I'm not familiar with actual algorithm of loop distribution, but I debugged= and found the point of divergence. loop_distribution::execute() loops thru loops_list (cfun, LI_ONLY_INNERMOST= ). The copy loop 7 (in both the builds) is processed but prepare_perfect_loop_nest() returns different values For single copy src loop, it deduces "perfect nesting" and returns outer lo= op 3. This essentially skips any further distribution of loop 7. For multi-loop src build, prepare_perfect_loop_nest() exits early as=20 outer->inner =3D=3D loop fails (outer loop 3 has inner pointing to scaling = loop 10, the last loop inside it, not 7 which is first). This causes further logic to eventually distribute it to 0 loop and memcpy. I'm not sure if this is a bug or intended, hence this report.=