On Wed, 13 May 2026 01:44:55 +0900,
Jeffrey Law wrote:
> 
> 
> 
> On 5/12/2026 5:40 AM, Richard Sandiford wrote:
> > Yoshinori Sato <[email protected]> writes:
> >> The LRA was confused and looping due to the definition of the register 
> >> class.
> >> The LRA yielded incorrect results because the manipulation of stack frames
> >> and the movement of double words relied heavily on existing reloads.
> >> These changes ensure that the correct code is generated even when the 
> >> "-mlra"
> >> option is specified.
> >> 
> >> v5 changes.
> >> - Moved the XEXP extractions inside the PLUS check in 
> >> rx_legitimize_address.
> >> - Replaced the magic number 8 with UNITS_PER_WORD * 2.
> >> - Fixed the C comment style.
> >> - Reverted the redundant changes in rx_modes_tieable_p.
> >> - Added the missing function comments for rx_get_subword, 
> >> rx_split_double_move,
> >>    and rx_relax_double_operands.
> >> - Removed the redundant checks in rx_relax_double_operands and fixed the
> >>    indentation.
> >> - Removed the redundant emit_insn and DONE in the movdi and movdf 
> >> expanders.
> >> - Replaced the output template of *ashlsi3_lra with "#" since it is
> >>    always split.
> > Thanks, LGTM.  Pushed to trunk as r17-468-g7ec6968058b393
> > (with a slightly tweaked changelog).
> THanks.  There's still work to do.  I spun my tester after this change
> on the rx port:
> 
> Tests that now fail, but worked before (431 tests):
> 
> I won't list them all.  Given how many are execution failures, there's
> likely a code generation failure in there somewhere.

The code extension was causing incorrect output.
Optimization mitigated this issue, so I didn't notice it.
The attached changes now allow the test to pass.

> A few of them:
> 
> rx-sim: gcc: gcc.c-torture/execute/20001009-2.c   -O0  execution test
> rx-sim: gcc: gcc.c-torture/execute/20020614-1.c   -O0  execution test
> rx-sim: gcc: gcc.c-torture/execute/20050410-1.c   -O1  execution test
> rx-sim: gcc: gcc.c-torture/execute/20050410-1.c   -O2  execution test
> rx-sim: gcc: gcc.c-torture/execute/20050410-1.c   -O2 -flto
> -fno-use-linker-plugin -flto-partition=none  execution test
> rx-sim: gcc: gcc.c-torture/execute/20050410-1.c   -O3 -g  execution test
> rx-sim: gcc: gcc.c-torture/execute/20050410-1.c   -Os  execution test
> rx-sim: gcc: gcc.c-torture/execute/921016-1.c   -O0  execution test
> rx-sim: gcc: gcc.c-torture/execute/960311-1.c   -O1  execution test
> rx-sim: gcc: gcc.c-torture/execute/960311-2.c   -O1  execution test
> rx-sim: gcc: gcc.c-torture/execute/980617-1.c   -O0  execution test
> rx-sim: gcc: gcc.c-torture/execute/990324-1.c   -O0  execution test
> rx-sim: gcc: gcc.c-torture/execute/990326-1.c   -O0  execution test
> 
> Anyway, seems like something for Yoshinori to look into.
> 
> Jeff

-- 
Yosinori Sato
>From ced589300731f25e5d64474eeafe38138d223af4 Mon Sep 17 00:00:00 2001
From: Yoshinori Sato <[email protected]>
Date: Sat, 16 May 2026 22:59:09 +0900
Subject: [PATCH] RX: The size of the mov instruction will be corrected

When expanding `extendqisi2` or `extendhisi2`, incorrect operation size
instructions were sometimes output.
This update ensures that the operation size is determined reliably.

gcc/config/rx/ChangeLog:

* rx.cc (rx_gen_move_template): Select the mode with the smallest size for the 
mov instruction.

Sigened-off-by: Yoshinori Sato <[email protected]>
---
 gcc/config/rx/rx.cc | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/gcc/config/rx/rx.cc b/gcc/config/rx/rx.cc
index 69f4b214fee..4078580f6ad 100644
--- a/gcc/config/rx/rx.cc
+++ b/gcc/config/rx/rx.cc
@@ -1000,10 +1000,26 @@ rx_gen_move_template (rtx * operands, bool is_movu)
   const char * dst_template;
   rtx          dest = operands[0];
   rtx          src  = operands[1];
+  machine_mode mode;
+  machine_mode src_mode;
 
-  /* Decide which extension, if any, should be given to the move instruction.  
*/
-  /* When zero-extending, always check the size of the source. */
-  switch ((is_movu || MEM_P (src)) ? GET_MODE (src) : GET_MODE (dest))
+  /* Determine the size to transfer.  */
+  if (CONST_INT_P (src))
+    /* Since constants have no size, the destination is used.  */
+    mode = GET_MODE (dest);
+  else
+    {
+      /* Otherwise, use the smaller size.  */
+      if (GET_MODE (src) == SIGN_EXTEND || GET_MODE (src) == ZERO_EXTEND)
+       /* When expanding, the original size will be used. */
+       src_mode = GET_MODE (XEXP (src, 0));
+      else
+       src_mode = GET_MODE (src);
+      mode = (GET_MODE_SIZE (src_mode) < GET_MODE_SIZE(GET_MODE(dest)))
+        ? src_mode : GET_MODE(dest);
+    }
+
+  switch (mode)
     {
     case E_QImode:
       /* The .B extension is not valid when
@@ -1022,9 +1038,6 @@ rx_gen_move_template (rtx * operands, bool is_movu)
       gcc_assert (!is_movu);
       extension = ".L";
       break;
-    case E_VOIDmode:
-      /* This mode is used by constants.  */
-      break;
     default:
       debug_rtx (src);
       gcc_unreachable ();
-- 
2.47.3

Reply via email to