https://gcc.gnu.org/g:cce99d1d045b56351e5ffd4fe8646bbb0188a069

commit r17-4144-gcce99d1d045b56351e5ffd4fe8646bbb0188a069
Author: Richard Sandiford <[email protected]>
Date:   Thu Sep 10 21:56:27 2026 +0100

    nds32: Fix rtx_costs return value
    
    rtx_costs is supposed to store the cost at 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 caused 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.
    
    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.

Diff:
---
 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 c8473e4257a4..cae7ed59f9ae 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))

Reply via email to