]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Make the RTL frontend set REG_NREGS correctly
authorRichard Sandiford <richard.sandiford@arm.com>
Wed, 9 Jul 2025 15:39:20 +0000 (16:39 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Wed, 9 Jul 2025 15:39:20 +0000 (16:39 +0100)
While working on a new testcase that uses the RTL frontend,
I hit a bug where a (reg ...) that spans multiple hard registers
had REG_NREGS set to 1.  This caused various things to misbehave.
For example, if the (reg ...) in question was used as crtl->return_rtx,
only the first register in the group would be marked as live on exit.

gcc/
* read-rtl-function.cc (function_reader::read_rtx_operand_r): Use
hard_regno_nregs to work out REG_NREGS for hard registers.

gcc/read-rtl-function.cc

index fb9c9554ea30cf85963f3aad2d112ce3f617796d..1f08c50cc12887c4c12059e5ecfb043fcaebd6dc 100644 (file)
@@ -1065,7 +1065,10 @@ function_reader::read_rtx_operand_r (rtx x)
   if (regno == -1)
     fatal_at (loc, "unrecognized register: '%s'", name.string);
 
-  set_regno_raw (x, regno, 1);
+  int nregs = 1;
+  if (HARD_REGISTER_NUM_P (regno))
+    nregs = hard_regno_nregs (regno, GET_MODE (x));
+  set_regno_raw (x, regno, nregs);
 
   /* Consolidate singletons.  */
   x = consolidate_singletons (x);