[Bug c/50286] New: Missed optimization, fails to propagate bool
gmaxwell at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Sep 3 23:35:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50286
Bug #: 50286
Summary: Missed optimization, fails to propagate bool
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: gmaxwell@gmail.com
GCC 4.7.0 (and prior) are unable to determine maximum loop counts in code that
looks like:
#include <stdio.h>
int main(int argc, char **argv)
{
int i;
const int flag=argc>1;
i=0;
do{
printf("%d\n",i*i);
}while(++i<1+flag);
return 0;
}
and so it doesn't unroll the loop.
If 1+flag is changed to 1+!!flag, 1+(bool)flag, or 1+(argc>1) then -O3 unrolls
the loop.
Interestingly, making flag type bool doesn't fix it and also doesn't unroll in
the 1+!!flag case.
More information about the Gcc-bugs
mailing list