rtx_costs is supposed to store the cost in a provided pointer
and return true if the cost is complete.  However, two places
in nds32_rtx_costs_speed_prefer returned the cost directly instead.
That in turn causes a build to fail with config-list.mk.

This doesn't seem to be an active port, so there's a legitimate
question whether we should preserve the existing behaviour
(by converting to return trues) or whether we should do what
the code presumably intended.  I've gone for the latter option here.

Tested with config-list.mk.  OK to install?

Richard


gcc/
        * config/nds32/nds32-cost.cc (nds32_rtx_costs_speed_prefer): Fix
        two places that returned a cost directly so that they now store
        the cost in *total and return true.
---
 gcc/config/nds32/nds32-cost.cc | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/config/nds32/nds32-cost.cc b/gcc/config/nds32/nds32-cost.cc
index c8473e4257a..cae7ed59f9a 100644
--- a/gcc/config/nds32/nds32-cost.cc
+++ b/gcc/config/nds32/nds32-cost.cc
@@ -217,10 +217,16 @@ nds32_rtx_costs_speed_prefer (rtx x ATTRIBUTE_UNUSED,
          /* We prefer (and (ior) (ior)) than (ior (and) (and)) for
             synthesize pk** and insb instruction.  */
          if (code == AND && GET_CODE (op0) == IOR && GET_CODE (op1) == IOR)
-           return COSTS_N_INSNS (1);
+           {
+             *total = COSTS_N_INSNS (1);
+             return true;
+           }
 
          if (code == IOR && GET_CODE (op0) == AND && GET_CODE (op1) == AND)
-           return COSTS_N_INSNS (10);
+           {
+             *total = COSTS_N_INSNS (10);
+             return true;
+           }
        }
 
       if (GET_MODE_SIZE (mode) >= GET_MODE_SIZE (DImode))
-- 
2.55.0

Reply via email to