https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67607
Bug ID: 67607 Summary: Failure to perform constant folding through type conversion Product: gcc Version: 6.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: miyuki at gcc dot gnu.org Target Milestone: --- This code is taken from PR67606: $ cat pr67606.c int f(int a[], int length) { int count=0; for (int i = 0 ; i < length ; i++) if (a[i] > 5) count++; return count; } $ g++ -S -O3 -fno-tree-vectorize pr67606.c -fverbose-asm -fdump-tree-optimized We get: <bb 3>: ivtmp.6_1 = (unsigned long) a_7(D); _19 = (unsigned int) length_4(D); _18 = _19 + 4294967295; _21 = (sizetype) _18; _22 = _21 + 1; _23 = _22 * 4; _24 = a_7(D) + _23; _25 = (unsigned long) _24; And this leads to generating some redundant code: leal -1(%rsi), %eax #, tmp114 leaq 4(%rdi,%rax,4), %rcx #, tmp111