public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/50136] New: Loop inc/dec optimization.
@ 2011-08-20  7:49 bratsinot at gmail dot com
  2011-08-21  9:20 ` [Bug c/50136] " rguenth at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: bratsinot at gmail dot com @ 2011-08-20  7:49 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50136
           Summary: Loop inc/dec optimization.
    Classification: Unclassified
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: bratsinot@gmail.com


Maybe shoud use inc and dec, than sub $1, %ebx?

GCC translate this C code:
 unsigned int i;
 scanf("%u", &i);
 for(unsigned int qwe=i; qwe>0; qwe--)
 printf("fg");

Into this Assembler code:
    leaq    12(%rsp), %rsi
    xorl    %eax, %eax
    movl    $.LC0, %edi
    call    __isoc99_scanf
    movl    12(%rsp), %ebx
    testl    %ebx, %ebx
    je    .L2
    .p2align 4,,10
    .p2align 3
.L4:
    xorl    %eax, %eax
    movl    $.LC1, %edi
    call    printf
    subl    $1, %ebx   ;This not good, dec %ebx is better
    jne    .L4


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

* [Bug c/50136] Loop inc/dec optimization.
  2011-08-20  7:49 [Bug c/50136] New: Loop inc/dec optimization bratsinot at gmail dot com
@ 2011-08-21  9:20 ` rguenth at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-08-21  9:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |WORKSFORME

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-08-21 09:20:05 UTC ---
inc/dec is chosen if you compile for selected CPUs where this is the
faster variant.


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

end of thread, other threads:[~2011-08-21  9:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-20  7:49 [Bug c/50136] New: Loop inc/dec optimization bratsinot at gmail dot com
2011-08-21  9:20 ` [Bug c/50136] " 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).