[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Why is gcc promoting on an unsigned char?
From: |
J.C. Wren |
Subject: |
[avr-gcc-list] Why is gcc promoting on an unsigned char? |
Date: |
Tue, 23 Dec 2003 00:58:41 -0500 |
User-agent: |
KMail/1.5.4 |
In this sample of code below, both i and data are defined as unsigned
char.
For some reason, GCC is effectively promoting i and data to an int for the
operations. The register tracking then fails to realize that it already has
r18 loaded at 0x98, and moves r24 back to r18, inspite of having just moved
r18 to r24.
By casting the (i << 1) to unsigned char, I can eliminate one
instruction,
but no amount of casting can further reduce out the promotion to int side
effects.
--jc
data |= (bit_is_set (DATAPIN, DATA) ? (i << 1) : 0);
80: 33 27 eor r19, r19
82: c9 9b sbis 0x19, 1 ; 25
84: 07 c0 rjmp .+14 ; 0x94
86: 84 2f mov r24, r20
88: 99 27 eor r25, r25
8a: 88 0f add r24, r24
8c: 99 1f adc r25, r25
8e: 82 2b or r24, r18
90: 93 2b or r25, r19
92: 02 c0 rjmp .+4 ; 0x98
94: 93 2f mov r25, r19
96: 82 2f mov r24, r18
98: 28 2f mov r18, r24
By casting the (i << 1) to unsigned char, I can eliminate one instruction
data |= (bit_is_set (DATAPIN, DATA) ? (unsigned char) (i << 1) : 0);
80: 33 27 eor r19, r19
82: c9 9b sbis 0x19, 1 ; 25
84: 06 c0 rjmp .+12 ; 0x92
86: 84 2f mov r24, r20
88: 88 0f add r24, r24
8a: 99 27 eor r25, r25
8c: 82 2b or r24, r18
8e: 93 2b or r25, r19
90: 02 c0 rjmp .+4 ; 0x96
92: 93 2f mov r25, r19
94: 82 2f mov r24, r18
96: 28 2f mov r18, r24
- [avr-gcc-list] Re: avr-gcc-list Digest, Vol 11, Issue 19, Ewout Boks, 2003/12/22
- [avr-gcc-list] Why is gcc promoting on an unsigned char?,
J.C. Wren <=
- [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, J.C. Wren, 2003/12/23
- RE: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, Rune Christensen, 2003/12/23
- Re: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, J.C. Wren, 2003/12/23
- Re: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, Jörgen Birkler, 2003/12/23
- Re: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, Neil Johnson, 2003/12/23
- Re: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, J.C. Wren, 2003/12/23
- Re: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, Neil Johnson, 2003/12/23
- Re: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, J.C. Wren, 2003/12/23
- Re: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, David Gay, 2003/12/23
- Re: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, J.C. Wren, 2003/12/23