]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Backport][PR69082][ARM]Backport "[PATCH][ARM]Tighten the conditions for
authorRenlin Li <renlin.li@arm.com>
Tue, 12 Jan 2016 17:32:18 +0000 (17:32 +0000)
committerRenlin Li <renlin@gcc.gnu.org>
Tue, 12 Jan 2016 17:32:18 +0000 (17:32 +0000)
arm_movw, arm_movt".

gcc/

2016-01-12  Renlin Li  <renlin.li@arm.com>

PR target/69082
Backport from mainline.
2015-08-24  Renlin Li  <renlin.li@arm.com>

* config/arm/arm-protos.h (arm_valid_symbolic_address_p): Declare.
* config/arm/arm.c (arm_valid_symbolic_address_p): Define.
* config/arm/arm.md (arm_movt): Use arm_valid_symbolic_address_p.
* config/arm/constraints.md ("j"): Add check for high code.

From-SVN: r232284

gcc/ChangeLog
gcc/config/arm/arm-protos.h
gcc/config/arm/arm.c
gcc/config/arm/arm.md
gcc/config/arm/constraints.md

index ddecc22573819546c22e4ff6dd8f2f4d3971dd19..c8221e44cd1e053b186e2bb33f51587cfc9812d9 100644 (file)
@@ -1,3 +1,14 @@
+2016-01-12  Renlin Li  <renlin.li@arm.com>
+
+       PR target/69082
+       Backport from mainline.
+       2015-08-24  Renlin Li  <renlin.li@arm.com>
+
+       * config/arm/arm-protos.h (arm_valid_symbolic_address_p): Declare.
+       * config/arm/arm.c (arm_valid_symbolic_address_p): Define.
+       * config/arm/arm.md (arm_movt): Use arm_valid_symbolic_address_p.
+       * config/arm/constraints.md ("j"): Add check for high code.
+
 2016-01-12  James Greenhalgh  <james.greenhalgh@arm.com>
 
        Backport from mainline.
index 2ac3b3009a204e6108ea161482c70bc06f7c3699..6b07a48087131c7ce51f6c922b0d81c5c582fddc 100644 (file)
@@ -282,6 +282,7 @@ extern int vfp3_const_double_for_bits (rtx);
 
 extern void arm_emit_coreregs_64bit_shift (enum rtx_code, rtx, rtx, rtx, rtx,
                                           rtx);
+extern bool arm_valid_symbolic_address_p (rtx);
 extern bool arm_validize_comparison (rtx *, rtx *, rtx *);
 #endif /* RTX_CODE */
 
index d9028a1aed6b7dc3448520b0d82a4ffc6b1c1733..3844275d39301154b6215e6152d1c3f6328abe7b 100644 (file)
@@ -31106,6 +31106,38 @@ arm_emit_coreregs_64bit_shift (enum rtx_code code, rtx out, rtx in,
   #undef BRANCH
 }
 
+/* Returns true if the pattern is a valid symbolic address, which is either a
+   symbol_ref or (symbol_ref + addend).
+
+   According to the ARM ELF ABI, the initial addend of REL-type relocations
+   processing MOVW and MOVT instructions is formed by interpreting the 16-bit
+   literal field of the instruction as a 16-bit signed value in the range
+   -32768 <= A < 32768.  */
+
+bool
+arm_valid_symbolic_address_p (rtx addr)
+{
+  rtx xop0, xop1 = NULL_RTX;
+  rtx tmp = addr;
+
+  if (GET_CODE (tmp) == SYMBOL_REF || GET_CODE (tmp) == LABEL_REF)
+    return true;
+
+  /* (const (plus: symbol_ref const_int))  */
+  if (GET_CODE (addr) == CONST)
+    tmp = XEXP (addr, 0);
+
+  if (GET_CODE (tmp) == PLUS)
+    {
+      xop0 = XEXP (tmp, 0);
+      xop1 = XEXP (tmp, 1);
+
+      if (GET_CODE (xop0) == SYMBOL_REF && CONST_INT_P (xop1))
+         return IN_RANGE (INTVAL (xop1), -0x8000, 0x7fff);
+    }
+
+  return false;
+}
 
 /* Returns true if a valid comparison operation and makes
    the operands in a form that is valid.  */
index 7ca816218a67dc424f12b9e2b9aec6d0bb088bdf..3bb8aef36f7ed54faeeb05f4b2b9825d96162f54 100644 (file)
   [(set (match_operand:SI 0 "nonimmediate_operand" "=r")
        (lo_sum:SI (match_operand:SI 1 "nonimmediate_operand" "0")
                   (match_operand:SI 2 "general_operand"      "i")))]
-  "arm_arch_thumb2"
+  "arm_arch_thumb2 && arm_valid_symbolic_address_p (operands[2])"
   "movt%?\t%0, #:upper16:%c2"
   [(set_attr "predicable" "yes")
    (set_attr "predicable_short_it" "no")
index 62da4fd3987131d09fb8b4f0dffe6b9422685bd6..aa3faaa970a1f762d2752e712545fccf79093aaf 100644 (file)
 (define_constraint "j"
  "A constant suitable for a MOVW instruction. (ARM/Thumb-2)"
  (and (match_test "TARGET_32BIT && arm_arch_thumb2")
-      (ior (match_code "high")
+      (ior (and (match_code "high")
+               (match_test "arm_valid_symbolic_address_p (XEXP (op, 0))"))
           (and (match_code "const_int")
-                (match_test "(ival & 0xffff0000) == 0")))))
+               (match_test "(ival & 0xffff0000) == 0")))))
 
 (define_constraint "Pj"
  "@internal A 12-bit constant suitable for an ADDW or SUBW instruction. (Thumb-2)"