Re: [PATCH] tree-ssa-math-opts: popcount (X) == 1 to (X ^ (X - 1)) > (X - 1) optimization [PR90693]

2023-11-20 Thread Jeff Law
On 11/20/23 01:39, Richard Biener wrote: On Mon, 20 Nov 2023, Jakub Jelinek wrote: On Mon, Nov 20, 2023 at 07:54:54AM +, Richard Biener wrote: On Fri, 17 Nov 2023, Jakub Jelinek wrote: Per the earlier discussions on this PR, the following patch folds popcount (x) == 1 (and != 1) into

Re: [PATCH] tree-ssa-math-opts: popcount (X) == 1 to (X ^ (X - 1)) > (X - 1) optimization [PR90693]

2023-11-20 Thread Jakub Jelinek
On Mon, Nov 20, 2023 at 08:39:42AM +, Richard Biener wrote: > I think it's fine as you posted (and Jeff approved), I'm just wondering > if we should rename that pass somehow ;) Note ISEL is more for > required pre-expansion stuff and widen-mul is for expansion related but > optimization

Re: [PATCH] tree-ssa-math-opts: popcount (X) == 1 to (X ^ (X - 1)) > (X - 1) optimization [PR90693]

2023-11-20 Thread Richard Biener
On Mon, 20 Nov 2023, Jakub Jelinek wrote: > On Mon, Nov 20, 2023 at 07:54:54AM +, Richard Biener wrote: > > On Fri, 17 Nov 2023, Jakub Jelinek wrote: > > > Per the earlier discussions on this PR, the following patch folds > > > popcount (x) == 1 (and != 1) into (x ^ (x - 1)) > x - 1 (or <=) >

Re: [PATCH] tree-ssa-math-opts: popcount (X) == 1 to (X ^ (X - 1)) > (X - 1) optimization [PR90693]

2023-11-20 Thread Jakub Jelinek
On Mon, Nov 20, 2023 at 07:54:54AM +, Richard Biener wrote: > On Fri, 17 Nov 2023, Jakub Jelinek wrote: > > Per the earlier discussions on this PR, the following patch folds > > popcount (x) == 1 (and != 1) into (x ^ (x - 1)) > x - 1 (or <=) > > if the corresponding popcount optab isn't

Re: [PATCH] tree-ssa-math-opts: popcount (X) == 1 to (X ^ (X - 1)) > (X - 1) optimization [PR90693]

2023-11-19 Thread Richard Biener
On Fri, 17 Nov 2023, Jakub Jelinek wrote: > Hi! > > Per the earlier discussions on this PR, the following patch folds > popcount (x) == 1 (and != 1) into (x ^ (x - 1)) > x - 1 (or <=) > if the corresponding popcount optab isn't implemented (I think any > double-word popcount or call will be

Re: [PATCH] tree-ssa-math-opts: popcount (X) == 1 to (X ^ (X - 1)) > (X - 1) optimization [PR90693]

2023-11-18 Thread Jeff Law
On 11/17/23 07:01, Jakub Jelinek wrote: Hi! Per the earlier discussions on this PR, the following patch folds popcount (x) == 1 (and != 1) into (x ^ (x - 1)) > x - 1 (or <=) if the corresponding popcount optab isn't implemented (I think any double-word popcount or call will be necessarily

[PATCH] tree-ssa-math-opts: popcount (X) == 1 to (X ^ (X - 1)) > (X - 1) optimization [PR90693]

2023-11-17 Thread Jakub Jelinek
Hi! Per the earlier discussions on this PR, the following patch folds popcount (x) == 1 (and != 1) into (x ^ (x - 1)) > x - 1 (or <=) if the corresponding popcount optab isn't implemented (I think any double-word popcount or call will be necessarily slower than the above cheap 3 op check and even