2002-09-26 Ulrich Weigand * reload.c (dup_replacements): New function. (find_reloads): Use it to duplicate replacements at the top level of match_dup operands. 2004-10-25 Jakub Jelinek * gcc.c-torture/execute/20041025-1.c: New test. --- gcc/reload.c.jj 2003-04-08 15:51:07.000000000 +0200 1.190 +++ gcc/reload.c 2004-10-25 13:10:48.056167117 +0200 1.191 @@ -244,6 +244,7 @@ static enum reg_class find_valid_class P unsigned int)); static int reload_inner_reg_of_subreg PARAMS ((rtx, enum machine_mode, int)); static void push_replacement PARAMS ((rtx *, int, enum machine_mode)); +static void dup_replacements PARAMS ((rtx *, rtx *)); static void combine_reloads PARAMS ((void)); static int find_reusable_reload PARAMS ((rtx *, rtx, enum reg_class, enum reload_type, int, int)); @@ -1578,6 +1579,25 @@ push_replacement (loc, reloadnum, mode) r->mode = mode; } } + +/* Duplicate any replacement we have recorded to apply at + location ORIG_LOC to also be performed at DUP_LOC. + This is used in insn patterns that use match_dup. */ + +static void +dup_replacements (dup_loc, orig_loc) + rtx *dup_loc; + rtx *orig_loc; +{ + int i, n = n_replacements; + + for (i = 0; i < n; i++) + { + struct replacement *r = &replacements[i]; + if (r->where == orig_loc) + push_replacement (dup_loc, r->what, r->mode); + } +} /* Transfer all replacements that used to be in reload FROM to be in reload TO. */ @@ -3969,9 +3989,7 @@ find_reloads (insn, replace, ind_levels, { int opno = recog_data.dup_num[i]; *recog_data.dup_loc[i] = *recog_data.operand_loc[opno]; - if (operand_reloadnum[opno] >= 0) - push_replacement (recog_data.dup_loc[i], operand_reloadnum[opno], - insn_data[insn_code_number].operand[opno].mode); + dup_replacements (recog_data.dup_loc[i], recog_data.operand_loc[opno]); } #if 0 --- gcc/testsuite/gcc.c-torture/execute/20041025-1.c.jj 2004-10-25 13:13:28.604657996 +0200 +++ gcc/testsuite/gcc.c-torture/execute/20041025-1.c 2004-10-25 13:11:43.119389360 +0200 @@ -0,0 +1,17 @@ +extern void abort (void); + +void +foo (int a, int b, int c, int d, int e, void **f) +{ + char g[4096]; + if (f == 0 || *f != 0) + abort (); +} + +int +main (void) +{ + void *x = 0; + foo (0, 1, 2, 3, 4, &x); + return 0; +}