From: DJ Delorie Date: Thu, 22 Feb 2018 16:36:48 +0000 (-0500) Subject: rx.c (rx_rtx_costs): New function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ea49b4dd2eb8d190f1470fea30dc582eceeee05d;p=gcc.git rx.c (rx_rtx_costs): New function. gcc/ * config/rx/rx.c (rx_rtx_costs): New function. (TARGET_RTX_COSTS): Override to use rx_rtx_costs. Co-Authored-By: Oleg Endo Co-Authored-By: Sebastian Perta From-SVN: r257905 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4643dd12eb2..eb4c5c91090 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-02-22 DJ Delorie + Sebastian Perta + Oleg Endo + + * config/rx/rx.c (rx_rtx_costs): New function. + (TARGET_RTX_COSTS): Override to use rx_rtx_costs. + 2018-02-22 Thomas Preud'homme * config/arm/t-multilib: Map Armv8-R to Armv7 multilibs. diff --git a/gcc/config/rx/rx.c b/gcc/config/rx/rx.c index 007e052c9a8..fe467f7bd3a 100644 --- a/gcc/config/rx/rx.c +++ b/gcc/config/rx/rx.c @@ -2992,6 +2992,62 @@ rx_address_cost (rtx addr, machine_mode mode ATTRIBUTE_UNUSED, return COSTS_N_INSNS (1); } +static bool +rx_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED, + int opno ATTRIBUTE_UNUSED, int* total, bool speed) +{ + if (x == const0_rtx) + { + *total = 0; + return true; + } + + switch (GET_CODE (x)) + { + case MULT: + if (mode == DImode) + { + *total = COSTS_N_INSNS (2); + return true; + } + /* fall through */ + + case PLUS: + case MINUS: + case AND: + case COMPARE: + case IOR: + case XOR: + *total = COSTS_N_INSNS (1); + return true; + + case DIV: + if (speed) + /* This is the worst case for a division. Pessimize divisions when + not optimizing for size and allow reciprocal optimizations which + produce bigger code. */ + *total = COSTS_N_INSNS (20); + else + *total = COSTS_N_INSNS (3); + return true; + + case UDIV: + if (speed) + /* This is the worst case for a division. Pessimize divisions when + not optimizing for size and allow reciprocal optimizations which + produce bigger code. */ + *total = COSTS_N_INSNS (18); + else + *total = COSTS_N_INSNS (3); + return true; + + default: + break; + } + + return false; +} + static bool rx_can_eliminate (const int from ATTRIBUTE_UNUSED, const int to) { @@ -3726,6 +3782,9 @@ rx_modes_tieable_p (machine_mode mode1, machine_mode mode2) #undef TARGET_MODES_TIEABLE_P #define TARGET_MODES_TIEABLE_P rx_modes_tieable_p +#undef TARGET_RTX_COSTS +#define TARGET_RTX_COSTS rx_rtx_costs + struct gcc_target targetm = TARGET_INITIALIZER; #include "gt-rx.h"