Hi, This patch declares loop index variable j as a 32 bit int instead of assuming ints are 32 bits. The smaller int size on the avr makes prior passes optimize away the loop exit check (j < 10000000), as the constant is outside the range of a 16 bit int.
Committed to trunk, after reg testing with avr and x86_64-pc-linux Regards Senthil gcc/testsuite/ChangeLog 2016-10-11 Senthil Kumar Selvaraj <senthil_kumar.selva...@atmel.com> * gcc.dg/tree-ssa/pr59597.c: Typedef __INT32_TYPE__ to i32. (main): Declare j as i32 instead of int. Index: gcc/testsuite/gcc.dg/tree-ssa/pr59597.c =================================================================== --- gcc/testsuite/gcc.dg/tree-ssa/pr59597.c (revision 240974) +++ gcc/testsuite/gcc.dg/tree-ssa/pr59597.c (working copy) @@ -4,6 +4,8 @@ typedef unsigned short u16; typedef unsigned char u8; typedef unsigned int u32; +__extension__ typedef __INT32_TYPE__ i32; + long int random(int); #define NNN 10 @@ -37,7 +39,7 @@ int main (int argc, char argv[]) { - int i, j; u16 crc; + int i; i32 j; u16 crc; for (j = 0; j < 10000000; j++) { for (i = 0; i < NNN; i++)