[Bug middle-end/90693] Missing popcount simplifications
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90693 Wilco changed: What|Removed |Added Status|UNCONFIRMED |ASSIGNED Last reconfirmed||2019-08-09 Assignee|unassigned at gcc dot gnu.org |wilco at gcc dot gnu.org Ever confirmed|0 |1
[Bug middle-end/90693] Missing popcount simplifications
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90693 --- Comment #3 from Dávid Bolvanský --- I measured it a bit.. (x-1)
[Bug middle-end/90693] Missing popcount simplifications
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90693 --- Comment #2 from Wilco --- (In reply to Dávid Bolvanský from comment #1) > >> __builtin_popcount (x) == 1 into x == (x & -x) > > > This will not work for x = 0. > > Should work: > x && x == (x & -x) > x && (x & x-1) == 0 Good point, though that's not needed for (x & (x-1)) != 0 given you can only have 2 or more bits set if x was non-zero to start with. It's worth finding a branchless sequence, otherwise it may not be faster. Maybe (x << clz (x)) == INT_MIN or (x-1)
[Bug middle-end/90693] Missing popcount simplifications
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90693 Dávid Bolvanský changed: What|Removed |Added CC||david.bolvansky at gmail dot com --- Comment #1 from Dávid Bolvanský --- >> __builtin_popcount (x) == 1 into x == (x & -x) This will not work for x = 0. Should work: x && x == (x & -x) x && (x & x-1) == 0