[Bug tree-optimization/97325] [11 Regression] wrong code with __builtin_ffs() at -O2

amacleod at redhat dot com gcc-bugzilla@gcc.gnu.org
Wed Oct 7 19:26:38 GMT 2020


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

Andrew Macleod <amacleod at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |amacleod at redhat dot com

--- Comment #3 from Andrew Macleod <amacleod at redhat dot com> ---
Created attachment 49327
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49327&action=edit
patch to always evaluate in unsigned

The range-op code for handling FFS and popcount doesn't take into account a
possibly negative parameter. 


The code was simply using the upper bound, which for [-65535, 0] was 0, we we
were getting a range o f[0, 0] instead of [0,32]

fix is to cast the range to unsigned before doing such calculation.

I'll add this patch to the test cycle.


More information about the Gcc-bugs mailing list