[Bug tree-optimization/90838] Detect table-based ctz implementation

2023-02-17 Thread wilco at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 --- Comment #21 from Wilco --- (In reply to Gabriel Ravier from comment #19) > If the original code being branchless makes it faster, wouldn't that imply > that we should use the table-based implementation when generating code for > `__builtin_c

[Bug tree-optimization/90838] Detect table-based ctz implementation

2023-02-17 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 --- Comment #20 from Jakub Jelinek --- No, because __builtin_ctz is branchless too, it just has UB when the argument is 0.

[Bug tree-optimization/90838] Detect table-based ctz implementation

2023-02-17 Thread gabravier at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 --- Comment #19 from Gabriel Ravier --- (In reply to Jakub Jelinek from comment #14) > The patch does: > +  bool zero_ok = CTZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (type), ctzval) > == 2; > + > +  /* Skip if there is no value defined at zero,

[Bug tree-optimization/90838] Detect table-based ctz implementation

2023-02-17 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 --- Comment #18 from Jakub Jelinek --- It is generally a win for cases where the condition can't be predicted, while if it can, jumps are much better. We have dozens or hundreds of PRs about this in either direction on x86.

[Bug tree-optimization/90838] Detect table-based ctz implementation

2023-02-17 Thread wilco at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 --- Comment #17 from Wilco --- (In reply to Jakub Jelinek from comment #16) > (In reply to Wilco from comment #15) > > It would make more sense to move x86 backends to CTZ_DEFINED_VALUE_AT_ZERO > > == 2 so that you always get the same result even

[Bug tree-optimization/90838] Detect table-based ctz implementation

2023-02-17 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 --- Comment #16 from Jakub Jelinek --- (In reply to Wilco from comment #15) > It would make more sense to move x86 backends to CTZ_DEFINED_VALUE_AT_ZERO > == 2 so that you always get the same result even when you don't have tzcnt. > A conditional

[Bug tree-optimization/90838] Detect table-based ctz implementation

2023-02-17 Thread wilco at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 --- Comment #15 from Wilco --- (In reply to Jakub Jelinek from comment #14) > The patch does: > +  bool zero_ok = CTZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (type), ctzval) > == 2; > + > +  /* Skip if there is no value defined at zero, or if we

[Bug tree-optimization/90838] Detect table-based ctz implementation

2023-02-17 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 --- Comment #14 from Jakub Jelinek --- The patch does: +  bool zero_ok = CTZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (type), ctzval) == 2; + +  /* Skip if there is no value defined at zero, or if we can't easily +return the correct value

[Bug tree-optimization/90838] Detect table-based ctz implementation

2023-02-16 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 --- Comment #13 from Andrew Pinski --- (In reply to Gabriel Ravier from comment #12) > It appears this new optimization is non-functional on trunk with x86-64... > specifically on x86-64, too, on AArch64 it works just fine. So does that > mean th

[Bug tree-optimization/90838] Detect table-based ctz implementation

2023-02-16 Thread gabravier at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 Gabriel Ravier changed: What|Removed |Added CC||gabravier at gmail dot com --- Comment

[Bug tree-optimization/90838] Detect table-based ctz implementation

2020-01-14 Thread tnfchris at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 Tamar Christina changed: What|Removed |Added Status|ASSIGNED|RESOLVED CC|

[Bug tree-optimization/90838] Detect table-based ctz implementation

2020-01-13 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 --- Comment #10 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=eb7c7c524556df5364f03adc20f6a9db20858484 commit r10-5912-geb7c7c524556df5364f03adc20f6a9db20858484 Author:

[Bug tree-optimization/90838] Detect table-based ctz implementation

2020-01-10 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 --- Comment #9 from Jakub Jelinek --- Author: jakub Date: Fri Jan 10 21:10:03 2020 New Revision: 280140 URL: https://gcc.gnu.org/viewcvs?rev=280140&root=gcc&view=rev Log: PR tree-optimization/90838 * tree-ssa-forwprop.c (simplify

[Bug tree-optimization/90838] Detect table-based ctz implementation

2020-01-10 Thread wilco at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 --- Comment #8 from Wilco --- Author: wilco Date: Fri Jan 10 19:32:53 2020 New Revision: 280132 URL: https://gcc.gnu.org/viewcvs?rev=280132&root=gcc&view=rev Log: PR90838: Support ctz idioms Support common idioms for count trailing zeroes using

[Bug tree-optimization/90838] Detect table-based ctz implementation

2019-08-09 Thread wilco at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 Wilco changed: What|Removed |Added Status|UNCONFIRMED |ASSIGNED Last reconfirmed|

[Bug tree-optimization/90838] Detect table-based ctz implementation

2019-06-12 Thread rguenther at suse dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 --- Comment #6 from rguenther at suse dot de --- On Wed, 12 Jun 2019, ktkachov at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 > > --- Comment #5 from ktkachov at gcc dot gnu.org --- > FWIW, there is another simil

[Bug tree-optimization/90838] Detect table-based ctz implementation

2019-06-12 Thread ktkachov at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 --- Comment #5 from ktkachov at gcc dot gnu.org --- FWIW, there is another similar function in deepsjeng that computes a side-effect: int myctz2 (unsigned long long * const b) { unsigned long long lsb = (*b) & -(*b); *b ^= lsb; return

[Bug tree-optimization/90838] Detect table-based ctz implementation

2019-06-12 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 --- Comment #4 from Jakub Jelinek --- I think it looks too complex to do it in match.pd, wouldn't it be better to do it say in tree-ssa-math-opts.c and thus just once? That said, due to the x & -x it is really bound to a small number of values th

[Bug tree-optimization/90838] Detect table-based ctz implementation

2019-06-12 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 Richard Biener changed: What|Removed |Added CC||rguenth at gcc dot gnu.org --- Comment

[Bug tree-optimization/90838] Detect table-based ctz implementation

2019-06-11 Thread wdijkstr at arm dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 Wilco changed: What|Removed |Added CC||wdijkstr at arm dot com --- Comment #2 from Wilc

[Bug tree-optimization/90838] Detect table-based ctz implementation

2019-06-11 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90838 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #1