This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/33970] Missed optimization using unsigned char loop variable
- From: "abnikant dot singh at atmel dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Sep 2010 12:09:12 -0000
- Subject: [Bug middle-end/33970] Missed optimization using unsigned char loop variable
- References: <bug-33970-15294@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #12 from abnikant dot singh at atmel dot com 2010-09-13 12:09 -------
I have verified the attached test case and test case with other comments and
found the code generated is correct i.e. the variable is not promoted to
integer in gcc-4.3.3, gcc-4.4.3, gcc-4.5.0 and also the latest head.
The assembly for the following piece of code:
int sub2(unsigned char); // external function
void foo(void) {
unsigned char x;
for(x=0;x<128; x++)
{
sub2(x); //x is becomes a int (16bit)
// sub2(x+1); //x is char (8bit)
}
}
in gcc-4.3.3 is:
foo:
push r17
/* prologue: function */
/* frame size = 0 */
ldi r17,lo8(0)
.L2:
mov r24,r17
rcall sub2
subi r17,lo8(-(1))
cpi r17,lo8(-128)
brne .L2
/* epilogue start */
pop r17
ret
.size foo, .-foo
--
abnikant dot singh at atmel dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |abnikant dot singh at atmel
| |dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33970