Re: [PATCH] Add missing popcount simplifications (PR90693)

2019-08-22 Thread Richard Biener
On Wed, Aug 21, 2019 at 5:53 PM Jeff Law wrote: > > On 8/21/19 7:57 AM, Wilco Dijkstra wrote: > > Hi Richard, > > > >>> > >>> I think this should be in expand stage where there could be comparison > >>> of the cost of the RTLs. > >> > >> I tend to agree here, if not then for the reason the "simpli

Re: [PATCH] Add missing popcount simplifications (PR90693)

2019-08-21 Thread Jeff Law
On 8/21/19 7:57 AM, Wilco Dijkstra wrote: > Hi Richard, > >>> >>> I think this should be in expand stage where there could be comparison >>> of the cost of the RTLs. >> >> I tend to agree here, if not then for the reason the "simplified" variants >> have more GIMPLE stmts which means they are not

Re: [PATCH] Add missing popcount simplifications (PR90693)

2019-08-21 Thread Wilco Dijkstra
Hi Richard, > > > > I think this should be in expand stage where there could be comparison > > of the cost of the RTLs. > > I tend to agree here, if not then for the reason the "simplified" variants > have more GIMPLE stmts which means they are not "simpler".  In > fact I'd argue for canonicaliza

Re: [PATCH] Add missing popcount simplifications (PR90693)

2019-08-14 Thread Richard Biener
On Tue, Aug 13, 2019 at 6:47 PM Andrew Pinski wrote: > > On Tue, Aug 13, 2019 at 8:50 AM Wilco Dijkstra wrote: > > > > Add simplifications for popcount (x) > 1 to (x & (x-1)) != 0 and > > popcount (x) == 1 into (x-1) > single-use cases and support an optional convert. A microbenchmark > > shows

Re: [PATCH] Add missing popcount simplifications (PR90693)

2019-08-13 Thread Andrew Pinski
On Tue, Aug 13, 2019 at 8:50 AM Wilco Dijkstra wrote: > > Add simplifications for popcount (x) > 1 to (x & (x-1)) != 0 and > popcount (x) == 1 into (x-1) single-use cases and support an optional convert. A microbenchmark > shows a speedup of 2-2.5x on both x64 and AArch64. > > Bootstrap OK, OK f

Re: [PATCH] Add missing popcount simplifications (PR90693)

2019-08-13 Thread Marc Glisse
On Tue, 13 Aug 2019, Wilco Dijkstra wrote: Add simplifications for popcount (x) > 1 to (x & (x-1)) != 0 and popcount (x) == 1 into (x-1) Is that true even on targets that have a popcount instruction? (-mpopcnt for x64) diff --git a/gcc/match.pd b/gcc/match.pd index 0317bc704f771f626ab7218

[PATCH] Add missing popcount simplifications (PR90693)

2019-08-13 Thread Wilco Dijkstra
Add simplifications for popcount (x) > 1 to (x & (x-1)) != 0 and popcount (x) == 1 into (x-1) gcc/ PR middle-end/90693 * match.pd: Add popcount simplifications. testsuite/ PR middle-end/90693 * gcc.dg/fold-popcount-5.c: Add new test. --- diff --git a/gcc/match.p