https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64183
Bug ID: 64183
Summary: [5.0 Regression] Complete unroll doesn't happen for a
while-loop
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: enkovich.gnu at gmail dot com
Created attachment 34189
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34189&action=edit
Reproducer
There is a performance regression in DENMark after r218142. Regression happens
because complete unroll computes max number of iterations for a while-loop in a
different way.
Reduced reproducer:
int bits;
unsigned int size;
int max_code;
void
test ()
{
int code = 0;
while (code < max_code)
code |= ((unsigned int) (size >> (--bits)));
while (bits < (unsigned int)25)
bits += 8;
}
Compilation string:
gcc -std=c90 -m32 -O3 test.c -c -fdump-tree-cunroll-details
Dump before r218142:
Analyzing # of iterations of loop 2
exit condition [(unsigned int) (prephitmp_33 + 8), + , 8] <= 24
bounds on difference of bases: -4294967271 ... 24
...
Loop 2 iterates at most 4 times.
Dump after r218142:
Analyzing # of iterations of loop 2
exit condition [(unsigned int) (prephitmp_36 + 8), + , 8] <= 24
bounds on difference of bases: -4294967271 ... 24
...
Loop 2 iterates at most 536870911 times.
While-loop condition has signed/unsigned comparison. But I believe the
original estimation of 4 iterations is correct.