Message ID | 20200915011946.3395-4-amodra@gmail.com |
---|---|
State | New |
Headers | show |
Series | [RS6000] rs6000_rtx_costs for AND | expand |
On Tue, 2020-09-15 at 10:49 +0930, Alan Modra via Gcc-patches wrote: > The existing "case AND" in this function is not sufficient for > optabs.c:avoid_expensive_constant usage, where the AND is passed in > outer_code. > > * config/rs6000/rs6000.c (rs6000_rtx_costs): Move costing for > AND to CONST_INT case. > > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c > index 32044d33977..523d029800a 100644 > --- a/gcc/config/rs6000/rs6000.c > +++ b/gcc/config/rs6000/rs6000.c > @@ -21150,16 +21150,13 @@ rs6000_rtx_costs (rtx x, machine_mode mode, > int outer_code, > || outer_code == MINUS) > && (satisfies_constraint_I (x) > || satisfies_constraint_L (x))) > - || (outer_code == AND > - && (satisfies_constraint_K (x) > - || (mode == SImode > - ? satisfies_constraint_L (x) > - : satisfies_constraint_J (x)))) > - || ((outer_code == IOR || outer_code == XOR) > + || ((outer_code == AND || outer_code == IOR || outer_code == > XOR) > && (satisfies_constraint_K (x) > || (mode == SImode > ? satisfies_constraint_L (x) > : satisfies_constraint_J (x)))) > + || (outer_code == AND > + && rs6000_is_valid_and_mask (x, mode)) > || outer_code == ASHIFT > || outer_code == ASHIFTRT > || outer_code == LSHIFTRT > @@ -21196,7 +21193,9 @@ rs6000_rtx_costs (rtx x, machine_mode mode, > int outer_code, > || outer_code == IOR > || outer_code == XOR) > && (INTVAL (x) > - & ~ (unsigned HOST_WIDE_INT) 0xffffffff) == 0)) > + & ~ (unsigned HOST_WIDE_INT) 0xffffffff) == 0) > + || (outer_code == AND > + && rs6000_is_valid_2insn_and (x, mode))) > { > *total = COSTS_N_INSNS (1); > return true; > @@ -21334,26 +21333,6 @@ rs6000_rtx_costs (rtx x, machine_mode mode, > int outer_code, > *total += COSTS_N_INSNS (1); > return true; > } > - > - /* rotate-and-mask (no rotate), andi., andis.: 1 insn. */ > - HOST_WIDE_INT val = INTVAL (XEXP (x, 1)); > - if (rs6000_is_valid_and_mask (XEXP (x, 1), mode) > - || (val & 0xffff) == val > - || (val & 0xffff0000) == val > - || ((val & 0xffff) == 0 && mode == SImode)) > - { > - *total = rtx_cost (left, mode, AND, 0, speed); > - *total += COSTS_N_INSNS (1); > - return true; > - } > - > - /* 2 insns. */ > - if (rs6000_is_valid_2insn_and (XEXP (x, 1), mode)) > - { > - *total = rtx_cost (left, mode, AND, 0, speed); > - *total += COSTS_N_INSNS (2); > - return true; > - } > } It's not exactly 1x1.. I tentatively conclude that the /* rotate-and- mask */ lump of code here does go dead with the "case AND" changes above. thanks -Will > > *total = COSTS_N_INSNS (1);
On Tue, Sep 15, 2020 at 01:15:34PM -0500, will schmidt wrote: > On Tue, 2020-09-15 at 10:49 +0930, Alan Modra via Gcc-patches wrote: > > The existing "case AND" in this function is not sufficient for > > optabs.c:avoid_expensive_constant usage, where the AND is passed in > > outer_code. > > > > * config/rs6000/rs6000.c (rs6000_rtx_costs): Move costing for > > AND to CONST_INT case. [snip] > It's not exactly 1x1.. I tentatively conclude that the /* rotate-and- > mask */ lump of code here does go dead with the "case AND" changes > above. It's not so much dead as duplicate. When rtx_costs returns false, as it will now on sub-expressions matching the removed code, it will be called recursively on the sub-expressions with outer_code set to the operation, AND in this case.
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 32044d33977..523d029800a 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -21150,16 +21150,13 @@ rs6000_rtx_costs (rtx x, machine_mode mode, int outer_code, || outer_code == MINUS) && (satisfies_constraint_I (x) || satisfies_constraint_L (x))) - || (outer_code == AND - && (satisfies_constraint_K (x) - || (mode == SImode - ? satisfies_constraint_L (x) - : satisfies_constraint_J (x)))) - || ((outer_code == IOR || outer_code == XOR) + || ((outer_code == AND || outer_code == IOR || outer_code == XOR) && (satisfies_constraint_K (x) || (mode == SImode ? satisfies_constraint_L (x) : satisfies_constraint_J (x)))) + || (outer_code == AND + && rs6000_is_valid_and_mask (x, mode)) || outer_code == ASHIFT || outer_code == ASHIFTRT || outer_code == LSHIFTRT @@ -21196,7 +21193,9 @@ rs6000_rtx_costs (rtx x, machine_mode mode, int outer_code, || outer_code == IOR || outer_code == XOR) && (INTVAL (x) - & ~ (unsigned HOST_WIDE_INT) 0xffffffff) == 0)) + & ~ (unsigned HOST_WIDE_INT) 0xffffffff) == 0) + || (outer_code == AND + && rs6000_is_valid_2insn_and (x, mode))) { *total = COSTS_N_INSNS (1); return true; @@ -21334,26 +21333,6 @@ rs6000_rtx_costs (rtx x, machine_mode mode, int outer_code, *total += COSTS_N_INSNS (1); return true; } - - /* rotate-and-mask (no rotate), andi., andis.: 1 insn. */ - HOST_WIDE_INT val = INTVAL (XEXP (x, 1)); - if (rs6000_is_valid_and_mask (XEXP (x, 1), mode) - || (val & 0xffff) == val - || (val & 0xffff0000) == val - || ((val & 0xffff) == 0 && mode == SImode)) - { - *total = rtx_cost (left, mode, AND, 0, speed); - *total += COSTS_N_INSNS (1); - return true; - } - - /* 2 insns. */ - if (rs6000_is_valid_2insn_and (XEXP (x, 1), mode)) - { - *total = rtx_cost (left, mode, AND, 0, speed); - *total += COSTS_N_INSNS (2); - return true; - } } *total = COSTS_N_INSNS (1);