https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97738

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
What about a version that still sets lowest_bit to value & -value; rather than
1 < ctz?
Also, I'm not sure you can safely do the (changed_bits >> ctz) >> 2 to
changed_bits >> (ctz + 2) transformation, while because of the division one can
count on value not being 0 (otherwise UB), value & -value can still be e.g. 1U
<< 31 and then ctz 31 too, and changed_bits >> (31 + 2) being UB, while
(changed_bits >> 31) >> 2 well defined returning 0.

So, I think we could e.g. during expansion (or isel) based on target cost
optimize
x / (y & -y) to x >> __builtin_ctz (y) (also assuming the optab for ctz
exists), but anything else looks complicated.

Reply via email to