]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rl78-expand.md (movqi): Handle (SUBREG (SYMBOL_REF)) properly.
authorNick Clifton <nickc@redhat.com>
Thu, 3 Apr 2014 13:02:27 +0000 (13:02 +0000)
committerNick Clifton <nickc@gcc.gnu.org>
Thu, 3 Apr 2014 13:02:27 +0000 (13:02 +0000)
* config/rl78/rl78-expand.md (movqi): Handle (SUBREG (SYMBOL_REF))
properly.

From-SVN: r209055

gcc/ChangeLog
gcc/config/rl78/rl78-expand.md

index 20447da43ba2e5ede7b8e6283cf656ff88ebd301..5d7eef5e68e1656888bc7391ca4c0e942cec4677 100644 (file)
@@ -1,3 +1,8 @@
+2014-04-03  Nick Clifton  <nickc@redhat.com>
+
+       * config/rl78/rl78-expand.md (movqi): Handle (SUBREG (SYMBOL_REF))
+       properly.
+
 2014-04-03  Martin Jambor  <mjambor@suse.cz>
 
        * ipa-cp.c (ipcp_verify_propagated_values): Also dump symtab and
index f794d7cb13dad235f8eeb35358d22eee6ee1bfb6..f61e444b5da8300eca695d071bb1e534094cb27e 100644 (file)
     if (rl78_far_p (operands[0]) && rl78_far_p (operands[1]))
       operands[1] = copy_to_mode_reg (QImode, operands[1]);
 
-    /* FIXME: Not sure how GCC can generate (SUBREG (SYMBOL_REF)),
-       but it does.  Since this makes no sense, reject it here.  */
+    /* GCC can generate (SUBREG (SYMBOL_REF)) when it has to store a symbol
+       into a bitfield, or a packed ordinary field.  We can handle this
+       provided that the destination is a register.  If not, then load the
+       source into a register first.  */
     if (GET_CODE (operands[1]) == SUBREG
-        && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
-      FAIL;
+        && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
+       && ! REG_P (operands[0]))
+       operands[1] = copy_to_mode_reg (QImode, operands[1]);
+
     /* Similarly for (SUBREG (CONST (PLUS (SYMBOL_REF)))).
        cf. g++.dg/abi/packed.C.  */
     if (GET_CODE (operands[1]) == SUBREG
        && GET_CODE (XEXP (operands[1], 0)) == CONST
         && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == PLUS
-        && GET_CODE (XEXP (XEXP (XEXP (operands[1], 0), 0), 0)) == SYMBOL_REF)
-      FAIL;
+        && GET_CODE (XEXP (XEXP (XEXP (operands[1], 0), 0), 0)) == SYMBOL_REF
+       && ! REG_P (operands[0]))
+       operands[1] = copy_to_mode_reg (QImode, operands[1]);
 
     if (CONST_INT_P (operands[1]) && ! IN_RANGE (INTVAL (operands[1]), (-1 << 8) + 1, (1 << 8) - 1))
       FAIL;