Hi DJ,

  Compiling this test case with the RL78 toolchain results in an ICE:

    unsigned char g_X;
    unsigned char g_Y;
    const __far unsigned char TabA[2][2] = { { 3, 0 }, { 4, 5 } };
    void main (void) { g_X = 1; g_Y = TabA[g_X][g_X]; }

  The problem appears to be that GCC will create a multiply-plus-add
  instruction to access the table regardless of whether the backend
  supports such an instruction.  I could not work out where in the
  middle end this was occurring, so instead I created the patch below
  which contains a splitter to separate out the multiply and addition
  operations.

  Tested with no regressions on an rl78-elf toolchain.

  OK to apply ?

Cheers
  Nick

gcc/ChangeLog
2015-03-03  Nick Clifton  <ni...@redhat.com>

        * config/rl78/rl78.md (muladdhi4): New splitter.

Index: gcc/config/rl78/rl78.md
===================================================================
--- gcc/config/rl78/rl78.md     (revision 221150)
+++ gcc/config/rl78/rl78.md     (working copy)
@@ -441,3 +441,15 @@
   ""
   ""
 )
+
+(define_insn_and_split "muladdhi4"
+  [(set (match_operand:HI                   0 "register_operand" "=&v")
+       (plus:HI (mult:HI (match_operand:HI 1 "general_operand"  "vi")
+                         (match_operand:HI 2 "general_operand"  "vi"))
+                (match_operand:HI          3 "register_operand" "v")))]
+  "! RL78_MUL_NONE"
+  "#"
+  ""
+  [(set (match_dup 0) (mult:HI (match_dup 1) (match_dup 2)))
+   (set (match_dup 0) (plus:HI (match_dup 0) (match_dup 3)))]
+)

Reply via email to