https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68329
zuogang <zuogang at huawei dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Target| |amd64 ppwerpc32 (tested) | |and others(no testing) Known to work| |4.4.1, 5.2.0 Host| |amd64 Known to fail| |4.8.5, 4.9.4 Build| |amd64 --- Comment #1 from zuogang <zuogang at huawei dot com> --- the src code file is: /* * compiling options: * -g -w -c -Wall -fno-common -fno-omit-frame-pointer -Wextra -Wformat-nonliteral -Wformat-security -Wswitch-default -O2 -fstrength-reduce -fno-strict-aliasing * * */ #define NULL 0 typedef unsigned int uint4; typedef unsigned short ushort; typedef unsigned long ulong; typedef struct team { ulong size; ulong count; ulong flag; ulong peer; ulong event; ulong index[1]; ulong addr; }Team; typedef struct entry { uint4 *p1; uint4 *p2; char simple[64]; char full[64]; uint4 index; }Entry; extern uint4 get1(uint4 p1, uint4 *p2); extern uint4 get2(uint4 p1, uint4 p2, Entry **p3); extern void hand(uint4 p1, uint4 p2, Entry *p3); void recvt(ushort id, Team *pTeam) { uint4 num = 0; uint4 index = 0; Entry *pEntry = NULL; uint4 count = 0; uint4 i = 0; if (0x01 & pTeam->flag) { count = pTeam->count; for (i = 0; i < count; i++) { index = *(pTeam->index + i); if(0 != get1(index, &num)) { continue; } if (0 == index) { continue; } if ( 0 != get2(num ,index, &pEntry)) { continue; } hand(num, pTeam->event, pEntry); } } return; } compile this file using : gcc -g -w -c -Wall -fno-common -fno-omit-frame-pointer -Wextra -Wformat-nonliteral -Wformat-security -Wswitch-default -O2 -fstrength-reduce -fno-strict-aliasing test-loop.c -o testloop see the disassemble file , wile find that the loop "for (i = 0; i < count; i++)" run only once. I think this "bug" is because gcc find the loop index "i", is a array's index, and the array 's len is 1, so gcc tell the loop can only run once, so gcc don't generate loop-specific asm codes. my question is why this op are not support in gcc version 5. any option to control this "bug"?