Hello, The following patch improves 64 bit operations by instructing GCC to use 16 bit movw instead of 8 bit mov. On the following test case the patch reduces the code size from 323 bytes to 245 bytes. unsigned long long my_anddi3(unsigned long long x, unsigned long long y){ return x & y; } I did not add this to the regression as it very simple and there many test cases in the regression especially c-torture which use this patch. Regression test is OK, tested with the following command: make -k check-gcc RUNTESTFLAGS=--target_board=rl78-sim
Please let me know if this is OK, Thank you! Sebastian Index: ChangeLog =================================================================== --- ChangeLog (revision 255538) +++ ChangeLog (working copy) @@ -1,3 +1,9 @@ +2017-12-12 Sebastian Perta <sebastian.pe...@renesas.com> + + * config/rl78/rl78-protos.h: New function declaration rl78_split_movdi + * config/rl78/rl78.md: New define_expand "movdi" + * config/rl78/rl78.c: New function definition rl78_split_movdi + 2017-12-10 Gerald Pfeifer <ger...@pfeifer.com> * doc/install.texi (Specific): Tweak link to mkssoftware.com. Index: config/rl78/rl78-protos.h =================================================================== --- config/rl78/rl78-protos.h (revision 255538) +++ config/rl78/rl78-protos.h (working copy) @@ -23,6 +23,7 @@ void rl78_expand_compare (rtx *); void rl78_expand_movsi (rtx *); void rl78_split_movsi (rtx *, machine_mode); +void rl78_split_movdi (rtx *, enum machine_mode); int rl78_force_nonfar_2 (rtx *, rtx (*gen)(rtx,rtx)); int rl78_force_nonfar_3 (rtx *, rtx (*gen)(rtx,rtx,rtx)); void rl78_expand_eh_epilogue (rtx); Index: config/rl78/rl78.c =================================================================== --- config/rl78/rl78.c (revision 255538) +++ config/rl78/rl78.c (working copy) @@ -596,6 +596,18 @@ } } +void +rl78_split_movdi (rtx *operands, enum machine_mode omode) +{ + rtx op00, op04, op10, op14; + op00 = rl78_subreg (SImode, operands[0], omode, 0); + op04 = rl78_subreg (SImode, operands[0], omode, 4); + op10 = rl78_subreg (SImode, operands[1], omode, 0); + op14 = rl78_subreg (SImode, operands[1], omode, 4); + emit_insn (gen_movsi (op00, op10)); + emit_insn (gen_movsi (op04, op14)); +} + /* Used by various two-operand expanders which cannot accept all operands in the "far" namespace. Force some such operands into registers so that each pattern has at most one far operand. */ Index: config/rl78/rl78.md =================================================================== --- config/rl78/rl78.md (revision 255538) +++ config/rl78/rl78.md (working copy) @@ -718,3 +718,11 @@ [(set_attr "valloc" "macax") (set_attr "is_g13_muldiv_insn" "yes")] ) + +(define_expand "movdi" + [(set (match_operand:DI 0 "nonimmediate_operand" "") + (match_operand:DI 1 "general_operand" ""))] + "" + "rl78_split_movdi(operands, DImode); + DONE;" +)