Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 36467
Product:  
Component:  
Status: NEW
Resolution:
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Eric Weddington <eric.weddington@atmel.com>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
test.i Test case with structure size == 16. text/plain 2008-06-08 17:57 169 bytes Edit
test2.i Test case with structure size == 17. text/plain 2008-06-08 17:58 172 bytes Edit
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 36467 depends on: Show dependency tree
Show dependency graph
Bug 36467 blocks: 39250

Additional Comments:





Mark bug as waiting for feedback
Mark bug as suspended




View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2008-06-08 18:20 Opened: 2008-06-08 17:56
From AVR Freaks forum:
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=453770#453770

Adding an offset to a pointer to a structure. If the structure size is 16, the
generated code is a loop with shifts. If the structure size is 17, the
generated code uses MUL* instructions and generates shorter code than when the
size is 16.

Command lines:
avr-gcc -save-temps -Os -mmcu=atmega32 -c test.c -o test.o
avr-gcc -save-temps -Os -mmcu=atmega32 -c test2.c -o test2.o

See the code generation of funct().

Test cases to follow...

------- Comment #1 From Eric Weddington 2008-06-08 17:57 -------
Created an attachment (id=15734) [edit]
Test case with structure size == 16.

------- Comment #2 From Eric Weddington 2008-06-08 17:58 -------
Created an attachment (id=15735) [edit]
Test case with structure size == 17.

------- Comment #3 From Eric Weddington 2008-06-08 18:08 -------
Generated code when structure size is 16 (test.i):

funct:
/* prologue: function */
/* frame size = 0 */
        lds r24,head
        mov r30,r24
        clr r31
        sbrc r30,7
        com r31
        ldi r24,4
1:      lsl r30
        rol r31
        dec r24
        brne 1b
        subi r30,lo8(-(qq))
        sbci r31,hi8(-(qq))
        ld r24,Z
        sbrc r24,1
        std Z+1,__zero_reg__
.L3:
        ret


Generated code when structure size is 17 (test2.i):

funct:
/* prologue: function */
/* frame size = 0 */
        lds r24,head
        ldi r25,lo8(17)
        muls r24,r25
        movw r30,r0
        clr r1
        subi r30,lo8(-(qq))
        sbci r31,hi8(-(qq))
        ld r24,Z
        sbrc r24,1
        std Z+1,__zero_reg__
.L3:
        ret

------- Comment #4 From Andy Hutchinson 2008-06-08 18:20 -------
It makes sense in one respect
We don't have fast shift by 4 bits and code defaults to loop for Os. Seems we
should be selective as MUL is indeed shorter.

Though I think gcc may be confused by our poor cost data and perhaps was alsp
mislead into using shift instead of MUL.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug