Re: [PATCH] Handling == or != comparisons that may affect range test optimization.

2013-11-05 Thread Jeff Law
On 11/05/13 15:00, Cong Hou wrote: Can you factor those two hunks of nearly identical code into a single function and call it twice? I'm also curious if you really need the code to swap lhs/rhs. When can the LHS of a cond be an integer constant? Don't we canonicalize it as ? I was not aw

Re: [PATCH] Handling == or != comparisons that may affect range test optimization.

2013-11-05 Thread Cong Hou
On Tue, Nov 5, 2013 at 12:23 PM, 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

Re: [PATCH] Handling == or != comparisons that may affect range test optimization.

2013-11-05 Thread Cong Hou
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. t

Re: [PATCH] Handling == or != comparisons that may affect range test optimization.

2013-11-05 Thread Jakub Jelinek
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) >

Re: [PATCH] Handling == or != comparisons that may affect range test optimization.

2013-11-05 Thread Jeff Law
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; ret

[PATCH] Handling == or != comparisons that may affect range test optimization.

2013-10-31 Thread Cong Hou
(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