+/* A mapper for mempcpy */
+int i_mapper_mempcpy(ir_node *call, void *ctx) {
+ ir_node *dst = get_Call_param(call, 0);
+ ir_node *src = get_Call_param(call, 1);
+ ir_node *len = get_Call_param(call, 2);
+ (void) ctx;
+
+ if (dst == src || (is_Const(len) && is_Const_null(len))) {
+ /* a memcpy(d, d, len) ==> d + len OR
+ /* a memcpy(d, s, 0) ==> d + 0 */
+ dbg_info *dbg = get_irn_dbg_info(call);
+ ir_node *mem = get_Call_mem(call);
+ ir_node *blk = get_nodes_block(call);
+ ir_mode *mode = get_irn_mode(dst);
+ ir_node *res = new_rd_Add(dbg, get_irn_irg(blk), blk, dst, len, mode);
+
+ DBG_OPT_ALGSIM0(call, res, FS_OPT_RTS_MEMPCPY);
+ replace_call(res, call, mem, NULL, NULL);
+ return 1;
+ }
+ return 0;
+} /* i_mapper_mempcpy */
+
+/* A mapper for memmove */
+int i_mapper_memmove(ir_node *call, void *ctx) {
+ ir_node *dst = get_Call_param(call, 0);
+ ir_node *src = get_Call_param(call, 1);
+ ir_node *len = get_Call_param(call, 2);
+ (void) ctx;
+
+ if (dst == src || (is_Const(len) && is_Const_null(len))) {
+ /* a memmove(d, d, len) ==> d OR
+ /* a memmove(d, s, 0) ==> d */
+ ir_node *mem = get_Call_mem(call);
+
+ DBG_OPT_ALGSIM0(call, dst, FS_OPT_RTS_MEMMOVE);
+ replace_call(dst, call, mem, NULL, NULL);
+ return 1;
+ }
+ return 0;
+} /* i_mapper_memmove */
+