https://gcc.gnu.org/g:277e73c868a1e655629109e5651c3a81f6292f53
commit r17-568-g277e73c868a1e655629109e5651c3a81f6292f53 Author: Yoshinori Sato <[email protected]> Date: Mon May 18 06:50:58 2026 -0600 [PATCH] RX: The size of the mov instruction will be corrected > 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. > 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. 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. 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/rx.cc (rx_gen_move_template): Select the mode with the smallest size for the mov instruction. Diff: --- 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 69f4b214fee6..4078580f6ad4 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 ();
