From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5071B3857437; Fri, 17 Feb 2023 17:16:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5071B3857437 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676654173; bh=Su7xPEaiqOA2G0AsSsjqFxXyiF7OXj1/FSOWS6AMUWE=; h=From:To:Subject:Date:From; b=bZjMf3PSln8hj6CjA1N04fGXW2YL6MJB+FdbyZo/m0FMvA/+1fF9AsJ9jIwmd224o yjEICyTpmp98hM62+UfTR7BniMPmZqACG5kshPE4DcsE+qQfUsUWRMzWeH0otNTLvI IJbQ/KLo05kiYnbeLbplhWvjd2ZhNdrc5VMXX3Xs= From: "tkoenig at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108839] New: Option for rerolling loops Date: Fri, 17 Feb 2023 17:16:12 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: tkoenig 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 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108839 Bug ID: 108839 Summary: Option for rerolling loops Product: gcc Version: unknown Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: tkoenig at gcc dot gnu.org Target Milestone: --- Code sometimes contains manual unrolling. For example, the BLAS reference implementation, subroutine DSCAL, has IF (INCX.EQ.1) THEN * * code for increment equal to 1 * * * clean-up loop * M =3D MOD(N,5) IF (M.NE.0) THEN DO I =3D 1,M DX(I) =3D DA*DX(I) END DO IF (N.LT.5) RETURN END IF MP1 =3D M + 1 DO I =3D MP1,N,5 DX(I) =3D DA*DX(I) DX(I+1) =3D DA*DX(I+1) DX(I+2) =3D DA*DX(I+2) DX(I+3) =3D DA*DX(I+3) DX(I+4) =3D DA*DX(I+4) END DO ELSE While such code may have been beneficial on old architectures, by now this disturbs the compiler's own unrolling and vectorization, and it increases code size. It could be beneficial to have a -freroll-loops option, which undid the manual unrolling of the code above. This could be stand-alone, or included in options such as -Os.=