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

Georg-Johann Lay <gjl at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
      Known to work|                            |4.6.1
         Resolution|                            |WORKSFORME

--- Comment #2 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2011-09-17 
18:35:52 UTC ---
Following test program

extern uint8_t leadingZeros[];

#define pgm_read(a,b) asm ("lpm %0,%a1" : "=r" (a) : "z" ((uint16_t)(b)))

uint8_t ldgZeroCntNormU32 (uint32_t* x)
{
  uint8_t zCount = 0;
  uint8_t shft;
  uint32_t quad = *x;

  while (!(uint8_t)(quad >> 24))
  {
    zCount += 8;
    quad <<=8;
  }
  pgm_read (shft, &leadingZeros[(uint8_t)(quad >> 24)]);
  *x = quad << shft;
  return zCount + shft;
}

yields with avr-gcc-4.6.1 -Os -mmcu=atmega8 -S following result:

ldgZeroCntNormU32:
    movw r26,r24
    ld r20,X+
    ld r21,X+
    ld r22,X+
    ld r23,X
    sbiw r26,3
    ldi r24,lo8(0)
    rjmp .L2
.L3:
    subi r24,lo8(-(8))
    mov r23,r22
    mov r22,r21
    mov r21,r20
    clr r20
.L2:
    mov r30,r23
    tst r23
    breq .L3
    ldi r31,lo8(0)
    subi r30,lo8(-(leadingZeros))
    sbci r31,hi8(-(leadingZeros))
/* #APP */
 ;  20 "foo.c" 1
    lpm r30,Z
 ;  0 "" 2
/* #NOAPP */
    mov r0,r30
    rjmp 2f
1:    lsl r20
    rol r21
    rol r22
    rol r23
2:    dec r0
    brpl 1b
    st X+,r20
    st X+,r21
    st X+,r22
    st X,r23
    sbiw r26,3
    add r24,r30
    ret

So there is no CLR for the while (!(uint8_t)(quad >> 24))

Closed as works for me.

Reply via email to