public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/108839] New: Option for rerolling loops
@ 2023-02-17 17:16 tkoenig at gcc dot gnu.org
  2023-02-17 17:19 ` [Bug tree-optimization/108839] " pinskia at gcc dot gnu.org
  2023-02-20  8:16 ` rguenth at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2023-02-17 17:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108839

            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 = MOD(N,5)
         IF (M.NE.0) THEN
            DO I = 1,M
               DX(I) = DA*DX(I)
            END DO
            IF (N.LT.5) RETURN
         END IF
         MP1 = M + 1
         DO I = MP1,N,5
            DX(I) = DA*DX(I)
            DX(I+1) = DA*DX(I+1)
            DX(I+2) = DA*DX(I+2)
            DX(I+3) = DA*DX(I+3)
            DX(I+4) = 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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug tree-optimization/108839] Option for rerolling loops
  2023-02-17 17:16 [Bug tree-optimization/108839] New: Option for rerolling loops tkoenig at gcc dot gnu.org
@ 2023-02-17 17:19 ` pinskia at gcc dot gnu.org
  2023-02-20  8:16 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-17 17:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108839

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note the SLP vectorizer should kick in for most cases of manually unrolled
loops.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug tree-optimization/108839] Option for rerolling loops
  2023-02-17 17:16 [Bug tree-optimization/108839] New: Option for rerolling loops tkoenig at gcc dot gnu.org
  2023-02-17 17:19 ` [Bug tree-optimization/108839] " pinskia at gcc dot gnu.org
@ 2023-02-20  8:16 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-02-20  8:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108839

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
             Blocks|                            |53947
   Last reconfirmed|                            |2023-02-20

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note the SLP loop vectorizer could be used to re-roll loops (for -Os?) by
vectorizing with one element vectors and a "fractional" VF.  I just never got
around playing with this idea (even when actually vectorizing but facing
highly manually unrolled code vectorizing with a single vector and a
"fractional" VF might be worth it for example for register pressure reasons).


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947
[Bug 53947] [meta-bug] vectorizer missed-optimizations

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-20  8:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-17 17:16 [Bug tree-optimization/108839] New: Option for rerolling loops tkoenig at gcc dot gnu.org
2023-02-17 17:19 ` [Bug tree-optimization/108839] " pinskia at gcc dot gnu.org
2023-02-20  8:16 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).