[gcc r17-2905] [committed] Fix recent msp430-elf regressions

Jeff Law via Gcc-cvs <[email protected]> Mon, 3 Aug 2026 20:49:22 +0000 (GMT)
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:011aa88be8bdcf7b09cc35d1c1cf9b3a3b7473d9

commit r17-2905-g011aa88be8bdcf7b09cc35d1c1cf9b3a3b7473d9
Author: Jeff Law <[email protected]>
Date:   Mon Aug 3 14:48:05 2026 -0600

    [committed] Fix recent msp430-elf regressions
    
    I didn't actually bisect this, but I strongly suspect this relates to the
    recent set INSN_CODE before calling insn_cost.
    
    An obscure corner case I didn't even know existed.  Inside combine we can
    create nop moves which look something like (set (pc) (pc)).  That would have
    triggered an early out in msp430_insn_cost.  After the combine change those
    insns use NOOP_MOVE_INSN_CODE via special hackery in combine rather than the -1
    for an unrecognized insn.
    
    So rather than early exit from msp430_insn_code, we try to call get_attr_length
    of that noop move which of course fails and triggers all kinds of testsuite
    regressions.
    
    While I considered checking earlier in the call stack, msp430 seems to be the
    only port affected, so I put it down in there.  Built and regression tested
    where it fixes the recent regressions and causes no new regressions.  Pushing
    to the trunk.
    
    gcc/
            * config/msp430/msp430.cc (msp430_insn_cost): Handle insns with
            NOOP_MOVE_INSN_CODE.

Diff:
---
 gcc/config/msp430/msp430.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/config/msp430/msp430.cc b/gcc/config/msp430/msp430.cc
index 671b95029d21..343041257edd 100644
--- a/gcc/config/msp430/msp430.cc
+++ b/gcc/config/msp430/msp430.cc
@@ -1657,6 +1657,9 @@ msp430_insn_cost (rtx_insn *insn, bool speed ATTRIBUTE_UNUSED)
   if (recog_memoized (insn) < 0)
     return 0;
 
+  if (INSN_CODE (insn) == NOOP_MOVE_INSN_CODE)
+    return 0;
+
   /* The returned cost must be relative to COSTS_N_INSNS (1). An insn with a
      length of 2 bytes is the smallest possible size and so must be equivalent
      to COSTS_N_INSNS (1).  */