------- Comment #3 from jingyu at google dot com 2010-01-29 23:59 ------- You must set "--param max-unswitch-level=0" to trigger the bug in non-FDO use.
I just tried gcc-4.2.4 on X86 platform. The problem exists. $ gcc loop.cpp -O3 --param max-unswitch-level=0 -m32 -S testl %eax, %eax jne .L5 xorl %eax, %eax .p2align 4,,7 .L7: addl $1, %eax <--- empty loop cmpl %edx, %eax jne .L7 xorl %ecx, %ecx By default, max-unswitch-level is 3. So if you don't change max-unswitch-level, after unswitch loop once, the conditions of nloop and loop can be simplified by recursive calls. Rather than writing a complicated test case which will do unswitch-loop 4 times, I would like to change the max-unswitch-level=0 to trigger the bug early. In FDO use, you can reproduce the bug with "-O2 -fprofile-use" on x86 with gcc-4.4.0 or higher. I have checked gcc-4.2.x. The check "if optimize_loop_for_size_p(loop)" is not in gcc-4.2.x. So gcc-4.2.x does not have this problem in FDO use. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42720