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

             Bug #: 54378
           Summary: code bloat for long << shifts
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: g...@gcc.gnu.org
            Target: avr


Something goes woring with cost computaton fir shifts:

long ashl32_7 (long x)
{
    return x << 7;
}

compiled with -O2 -dp -mmcu=atmega8 -S -fno-split-wide-types
results in


ashl32_7:
/* DEBUG: cost = 32.  */
    lsl r22     ;  27    *ashlsi3_const/4    [length = 8]
    rol r23
    rol r24
    rol r25
    lsl r22
    rol r23
    rol r24
    rol r25
/* DEBUG: cost = 32.  */
    lsl r22     ;  28    *ashlsi3_const/4    [length = 8]
    rol r23
    rol r24
    rol r25
    lsl r22
    rol r23
    rol r24
    rol r25
/* DEBUG: cost = 32.  */
    lsl r22     ;  29    *ashlsi3_const/4    [length = 8]
    rol r23
    rol r24
    rol r25
    lsl r22
    rol r23
    rol r24
    rol r25
/* DEBUG: cost = 16.  */
    lsl r22     ;  30    *ashlsi3_const/2    [length = 4]
    rol r23
    rol r24
    rol r25
/* DEBUG: pattern-cost = 4.  */
    ret     ;  26    return    [length = 1]


The insns are already there at .expand

Reply via email to