On Fri, Jun 09, 2017 at 02:35:45PM +0200, Richard Biener wrote: > +static bool > +gimple_fold_builtin_bcmp (gimple_stmt_iterator *gsi) > +{ > > + /* Transform bcmp (a, b, len) into memcmp (a, b, len). */ > + > + gimple *stmt = gsi_stmt (*gsi); > + tree a = gimple_call_arg (stmt, 0); > + tree b = gimple_call_arg (stmt, 1); > + tree len = gimple_call_arg (stmt, 2); > + > + gimple_seq seq = NULL; > + gimple *repl = gimple_build_call (fn, 3, a, b, len); > + gimple_seq_add_stmt_without_update (&seq, repl); > + gsi_replace_with_seq_vops (gsi, seq); > > given they have the same prototype you can do like gimple_fold_builtin_stpcpy: > > gimple_call_set_fndecl (stmt, fn); > fold_stmt (gsi); > > That works even with bcopy -> memmove if you swap arguments.
Shouldn't it also update gimple_call_fntype though, at least for memmove? Those differ with void const * vs. void * arguments, and also in the return value. At least if the old fntype is compatible with the bcopy call. Jakub