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

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
There is so much special handling of all these built-ins in so many places that
makes keeping them all in sync with one another tricky business.  I think it
would help if more of the salient properties of the major built-ins were
abstracted into general attributes and the handling code simplified to test for
the attributes instead.  For instance, if there were a helper, say 'bool
is_call_bzero_like_p (gimple *)' then code similar to this (tree-ssa-sccvn.c)

  if (((gimple_call_builtin_p (def_stmt, BUILT_IN_MEMSET))
       && integer_zerop (gimple_call_arg (def_stmt, 1))
       && tree_fits_uhwi_p (gimple_call_arg (def_stmt, 2)))
      || gimple_call_builtin_p (def_stmt, BUILT_IN_BZERO))

(that's currently missing the the BUILT_IN_BZERO test) could call
is_call_bzero_like_p(call) instead, and would handle not just these two
built-ins but any other built-in or user-defined function decorated with the
same attributes.

Transforming bzero() into memset(0) would get around the problem in the case
oif these two but not all equivalent built-ins can be easily transformed
without making compromises.  For example, transforming mempcpy to memcpy is
probably not a good approach to dealing with the problem.

Reply via email to