Re: [PATCH] phiopt: Optimize (x <=> y) cmp z [PR94589]

2021-05-15 Thread Marc Glisse
On Fri, 14 May 2021, Jakub Jelinek via Gcc-patches wrote: On Thu, May 06, 2021 at 09:42:41PM +0200, Marc Glisse wrote: We can probably do it in 2 steps, first something like (for cmp (eq ne) (simplify (cmp (bit_and:c @0 @1) @0) (cmp (@0 (bit_not! @1)) { build_zero_cst (TREE_TYPE (@0));

Re: [PATCH] phiopt: Optimize (x <=> y) cmp z [PR94589]

2021-05-14 Thread Jakub Jelinek via Gcc-patches
On Thu, May 06, 2021 at 09:42:41PM +0200, Marc Glisse wrote: > We can probably do it in 2 steps, first something like > > (for cmp (eq ne) > (simplify > (cmp (bit_and:c @0 @1) @0) > (cmp (@0 (bit_not! @1)) { build_zero_cst (TREE_TYPE (@0)); }))) > > to get rid of the double use, and then

Re: [PATCH] phiopt: Optimize (x <=> y) cmp z [PR94589]

2021-05-06 Thread Marc Glisse
On Thu, 6 May 2021, Jakub Jelinek via Gcc-patches wrote: Though, (x&1) == x is equivalent to both (x&~1)==0 and to x < 2U and from the latter two it isn't obvious which one is better/more canonical. On aarch64 I don't see differences in number of insns nor in their size: 10:13001c00

Re: [PATCH] phiopt: Optimize (x <=> y) cmp z [PR94589]

2021-05-06 Thread Jakub Jelinek via Gcc-patches
On Wed, May 05, 2021 at 06:52:27PM +0200, Jakub Jelinek via Gcc-patches wrote: > On Wed, May 05, 2021 at 01:45:29PM +0200, Marc Glisse wrote: > > On Tue, 4 May 2021, Jakub Jelinek via Gcc-patches wrote: > > > > > 2) the pr94589-2.C testcase should be matching just 12 times each, but > > > runs >

Re: [PATCH] phiopt: Optimize (x <=> y) cmp z [PR94589]

2021-05-05 Thread Jakub Jelinek via Gcc-patches
On Wed, May 05, 2021 at 01:45:29PM +0200, Marc Glisse wrote: > On Tue, 4 May 2021, Jakub Jelinek via Gcc-patches wrote: > > > 2) the pr94589-2.C testcase should be matching just 12 times each, but runs > > into operator>=(strong_ordering, unspecified) being defined as > > (_M_value&1)==_M_value >

Re: [PATCH] phiopt: Optimize (x <=> y) cmp z [PR94589]

2021-05-05 Thread Martin Sebor via Gcc-patches
On 5/4/21 1:44 AM, Jakub Jelinek via Gcc-patches wrote: Hi! genericize_spaceship genericizes i <=> j to approximately ({ int c; if (i == j) c = 0; else if (i < j) c = -1; else c = 1; c; }) for strong ordering and ({ int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else

Re: [PATCH] phiopt: Optimize (x <=> y) cmp z [PR94589]

2021-05-05 Thread Marc Glisse
On Tue, 4 May 2021, Jakub Jelinek via Gcc-patches wrote: 2) the pr94589-2.C testcase should be matching just 12 times each, but runs into operator>=(strong_ordering, unspecified) being defined as (_M_value&1)==_M_value rather than _M_value>=0. When not honoring NaNs, the 2 case should be

Re: [PATCH] phiopt: Optimize (x <=> y) cmp z [PR94589]

2021-05-05 Thread Richard Biener
On Tue, 4 May 2021, Jakub Jelinek wrote: > Hi! > > genericize_spaceship genericizes i <=> j to approximately > ({ int c; if (i == j) c = 0; else if (i < j) c = -1; else c = 1; c; }) > for strong ordering and > ({ int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; > else c

Re: [PATCH] phiopt: Optimize (x <=> y) cmp z [PR94589]

2021-05-04 Thread Jakub Jelinek via Gcc-patches
On Tue, May 04, 2021 at 10:42:12AM +0100, Jonathan Wakely wrote: > > There are two things I'd like to address in a follow-up: > > 1) if (HONOR_NANS (TREE_TYPE (lhs1)) || HONOR_SIGNED_ZEROS (TREE_TYPE > > (lhs1))) > > is what I've copied from elsewhere in phiopt, but thinking about it, > > alll we

Re: [PATCH] phiopt: Optimize (x <=> y) cmp z [PR94589]

2021-05-04 Thread Jonathan Wakely via Gcc-patches
On 04/05/21 09:44 +0200, Jakub Jelinek wrote: Hi! genericize_spaceship genericizes i <=> j to approximately ({ int c; if (i == j) c = 0; else if (i < j) c = -1; else c = 1; c; }) for strong ordering and ({ int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; c;