It seems there are some changes in GCC. But if you change the type of n into signed int, the issue appears again:
int foo(int n) { if (n != 0) if (n != 1) if (n != 2) if (n != 3) if (n != 4) return ++n; return n; } Also, ifcombine also suffers from the same issue here. thanks, Cong On Tue, Nov 5, 2013 at 12:53 PM, Jakub Jelinek <ja...@redhat.com> wrote: > On Tue, Nov 05, 2013 at 01:23:00PM -0700, Jeff Law wrote: >> On 10/31/13 18:03, Cong Hou wrote: >> >(This patch is for the bug 58728: >> >http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58728) >> > >> >As in the bug report, consider the following loop: >> > >> >int foo(unsigned int n) >> >{ >> > if (n != 0) >> > if (n != 1) >> > if (n != 2) >> > if (n != 3) >> > if (n != 4) >> > return ++n; >> > return n; >> >} >> > >> >The range test optimization should be able to merge all those five >> >conditions into one in reassoc pass, but I fails to do so. The reason >> >is that the phi arg of n is replaced by the constant it compares to in >> >case of == or != comparisons (in vrp pass). GCC checks there is no >> >side effect on n between any two neighboring conditions by examining >> >if they defined the same phi arg in the join node. But as the phi arg >> >is replace by a constant, the check fails. > > I can't reproduce this, at least not on x86_64-linux with -O2, > the ifcombine pass already merges those. > > Jakub