From: Toon Moene Date: Mon, 9 Jul 2001 20:21:48 +0000 (+0200) Subject: expr.h: Adjust prototypes for have_add2_insn, have_sub2_insn. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fb7e77d7dc2d25794f2c62d8c4f2f751dc772bf4;p=gcc.git expr.h: Adjust prototypes for have_add2_insn, have_sub2_insn. 2001-07-09 Toon Moene * expr.h: Adjust prototypes for have_add2_insn, have_sub2_insn. * optabs.c (have_add2_insn): Check whether the add insn chosen really accepts the operands. (have_sub2_insn): Ditto for sub insn. * reload1.c (reload_cse_move2add): Adjust calls of have_add2_insn. From-SVN: r43874 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b7b60912c84..12165fad5ce 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2001-07-09 Toon Moene + + * expr.h: Adjust prototypes for have_add2_insn, have_sub2_insn. + * optabs.c (have_add2_insn): Check whether the add insn chosen + really accepts the operands. (have_sub2_insn): Ditto for sub insn. + * reload1.c (reload_cse_move2add): Adjust calls of have_add2_insn. + +*************** extern rtx gen_add2_insn PARAMS ((rtx, r Mon Jul 9 13:26:40 2001 Jeffrey A Law (law@cygnus.com) * Makefile.in (OBJS): Add ssa-ccp.o diff --git a/gcc/expr.h b/gcc/expr.h index 4808dc342c0..cf2cb268ef3 100644 --- a/gcc/expr.h +++ b/gcc/expr.h @@ -841,8 +841,8 @@ int can_conditionally_move_p PARAMS ((enum machine_mode mode)); extern rtx gen_add2_insn PARAMS ((rtx, rtx)); extern rtx gen_sub2_insn PARAMS ((rtx, rtx)); extern rtx gen_move_insn PARAMS ((rtx, rtx)); -extern int have_add2_insn PARAMS ((enum machine_mode)); -extern int have_sub2_insn PARAMS ((enum machine_mode)); +extern int have_add2_insn PARAMS ((rtx, rtx)); +extern int have_sub2_insn PARAMS ((rtx, rtx)); /* Return the INSN_CODE to use for an extend operation. */ extern enum insn_code can_extend_p PARAMS ((enum machine_mode, diff --git a/gcc/optabs.c b/gcc/optabs.c index 16e1b08d87c..57c87fad16d 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -3765,10 +3765,28 @@ gen_add2_insn (x, y) } int -have_add2_insn (mode) - enum machine_mode mode; +have_add2_insn (x, y) + rtx x, y; { - return add_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing; + int icode; + + if (GET_MODE (x) == VOIDmode) + abort (); + + icode = (int) add_optab->handlers[(int) GET_MODE (x)].insn_code; + + if (icode == CODE_FOR_nothing) + return 0; + + if (! ((*insn_data[icode].operand[0].predicate) + (x, insn_data[icode].operand[0].mode)) + || ! ((*insn_data[icode].operand[1].predicate) + (x, insn_data[icode].operand[1].mode)) + || ! ((*insn_data[icode].operand[2].predicate) + (y, insn_data[icode].operand[2].mode))) + return 0; + + return 1; } /* Generate and return an insn body to subtract Y from X. */ @@ -3791,10 +3809,28 @@ gen_sub2_insn (x, y) } int -have_sub2_insn (mode) - enum machine_mode mode; +have_sub2_insn (x, y) + rtx x, y; { - return sub_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing; + int icode; + + if (GET_MODE (x) == VOIDmode) + abort (); + + icode = (int) sub_optab->handlers[(int) GET_MODE (x)].insn_code; + + if (icode == CODE_FOR_nothing) + return 0; + + if (! ((*insn_data[icode].operand[0].predicate) + (x, insn_data[icode].operand[0].mode)) + || ! ((*insn_data[icode].operand[1].predicate) + (x, insn_data[icode].operand[1].mode)) + || ! ((*insn_data[icode].operand[2].predicate) + (y, insn_data[icode].operand[2].mode))) + return 0; + + return 1; } /* Generate the body of an instruction to copy Y into X. diff --git a/gcc/reload1.c b/gcc/reload1.c index 78851c0a147..c6a5c238548 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -9161,7 +9161,7 @@ reload_cse_move2add (first) if (new_src == const0_rtx) success = validate_change (insn, &SET_SRC (pat), reg, 0); else if (rtx_cost (new_src, PLUS) < rtx_cost (src, SET) - && have_add2_insn (GET_MODE (reg))) + && have_add2_insn (reg, new_src)) success = validate_change (insn, &PATTERN (insn), gen_add2_insn (reg, new_src), 0); reg_set_luid[regno] = move2add_luid; @@ -9212,7 +9212,7 @@ reload_cse_move2add (first) = validate_change (next, &SET_SRC (set), reg, 0); else if ((rtx_cost (new_src, PLUS) < COSTS_N_INSNS (1) + rtx_cost (src3, SET)) - && have_add2_insn (GET_MODE (reg))) + && have_add2_insn (reg, new_src)) success = validate_change (next, &PATTERN (next), gen_add2_insn (reg, new_src), 0);