+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.
Ok with that changes.
I made these changes along with those mentioned downthread and
committed r249278.
Martin