public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/32729]  New: Loop unrolling not performed with large constant loop bound
@ 2007-07-11 16:01 scovich at gmail dot com
  2007-07-11 16:36 ` [Bug middle-end/32729] " scovich at gmail dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: scovich at gmail dot com @ 2007-07-11 16:01 UTC (permalink / raw)
  To: gcc-bugs

Consider the following functions:

// g++ -mtune=core2 -O3 -S -dp
void loop(int* dest, int* src, int count) {
  for(int i=0; i < count; i++)
    dest[i] = src[i];
}
void loop_few(int* dest, int* src) { loop(dest, src, 8); }
void loop_many(int* dest, int* src) { loop(dest, src, 64); }

loop() unrolls 8x, as expected. loop_few() peels completely, as expected.
However, loop_many() neither peels nor unrolls. 

_Z9loop_manyPiS_:
        xorl    %edx, %edx      # 34    *movdi_xor_rex64        [length = 2]
.L47:
        movl    (%rsi,%rdx,4), %eax     # 11    *movsi_1/1      [length = 3]
        movl    %eax, (%rdi,%rdx,4)     # 12    *movsi_1/2      [length = 3]
        incq    %rdx    # 13    *adddi_1_rex64/1        [length = 3]
        cmpq    $64, %rdx       # 15    cmpdi_1_insn_rex64/1    [length = 4]
        jne     .L47    # 16    *jcc_1  [length = 2]
        rep ; ret       # 35    return_internal_long    [length = 1]            

Ideally the optimizer would unroll 8x, then notice that (count%8==0) and
eliminate the partial unroll code. However, even a stock unroll would be better
than nothing.


-- 
           Summary: Loop unrolling not performed with large constant loop
                    bound
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: scovich at gmail dot com
GCC target triplet: x86_64-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32729


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

end of thread, other threads:[~2007-07-15 20:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-11 16:01 [Bug middle-end/32729] New: Loop unrolling not performed with large constant loop bound scovich at gmail dot com
2007-07-11 16:36 ` [Bug middle-end/32729] " scovich at gmail dot com
2007-07-11 16:37 ` [Bug middle-end/32729] Regression: " scovich at gmail dot com
2007-07-11 20:48 ` rakdver at gcc dot gnu dot org
2007-07-11 20:56 ` rakdver at gcc dot gnu dot org
2007-07-12  7:36 ` [Bug rtl-optimization/32729] " rakdver at gcc dot gnu dot org
2007-07-12 10:24 ` rakdver at gcc dot gnu dot org
2007-07-15 20:53 ` [Bug rtl-optimization/32729] [4.3 Regression] : " pinskia at gcc dot gnu dot 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).