http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29776

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

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

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 30453
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30453&action=edit
gcc49-pr29776.patch

Untested VRP patch.  There is SSA_NAME_RANGE_INFO support being reviewed
currently which will make VRP info persistent and some zero/sign-extension pass
that makes use of that info, perhaps that will take care of the rest.

I'm not 100% sure about CLZ/CTZ in the patch, because it could return any value
for argument of 0, but as we document it as undefined behavior, perhaps it is
fine.

With more code we could do even better than this and define from argument's VR
smaller VR_RANGE than this patch does, say for ffs if 0 isn't in the VR_RANGE
of the argument, the minimum value of the builtin won't be 0, but 1, and from
maximum value we could take floor_log of the maximum value plus 1 as the
maximum of the resulting range.  Ditto for popcount, for parity the current [0,
1] is sufficient, for clz we could use precision minus floor_log of the maximum
value
as the minimum of resulting vr, for ctz derive from it maximum.  Dunno if it is
worth it though.

Reply via email to