Hi Thomas,

This looks mostly good with a few nits inline.
Please repost with the comments addressed.

Thanks,
Kyrill

On 17/05/16 11:13, Thomas Preudhomme wrote:
Ping?

*** gcc/ChangeLog ***

2015-11-13  Thomas Preud'homme  <thomas.preudho...@arm.com>

         * config/arm/arm.h (TARGET_HAVE_MOVT): Include ARMv8-M as having MOVT.
         * config/arm/arm.c (arm_arch_name): (const_ok_for_op): Check MOVT/MOVW
         availability with TARGET_HAVE_MOVT.
         (thumb_legitimate_constant_p): Legalize high part of a label_ref as a
         constant.

I don't think "Legalize" is the right word here. How about "Strip the HIGH part of a 
label_ref"?

         (thumb1_rtx_costs): Also return 0 if setting a half word constant and
         movw is available.
         (thumb1_size_rtx_costs): Make set of half word constant also cost 1
         extra instruction if MOVW is available.  Make constant with bottom
half
         word zero cost 2 instruction if MOVW is available.
         * config/arm/arm.md (define_attr "arch"): Add v8mb.
         (define_attr "arch_enabled"): Set to yes if arch value is v8mb and
         target is ARMv8-M Baseline.
         * config/arm/thumb1.md (thumb1_movdi_insn): Add ARMv8-M Baseline only
         alternative for constants satisfying j constraint.
         (thumb1_movsi_insn): Likewise.
         (movsi splitter for K alternative): Tighten condition to not trigger
         if movt is available and j constraint is satisfied.
         (Pe immediate splitter): Likewise.
         (thumb1_movhi_insn): Add ARMv8-M Baseline only alternative for
         constant fitting in an halfword to use movw.

Please use 'MOVW' consistently in the ChangeLog rather than the lowercase 'movw'

         * doc/sourcebuild.texi (arm_thumb1_movt_ko): Document new ARM
         effective target.


*** gcc/testsuite/ChangeLog ***

2015-11-13  Thomas Preud'homme  <thomas.preudho...@arm.com>

         * lib/target-supports.exp (check_effective_target_arm_thumb1_movt_ko):
         Define effective target.
         * gcc.target/arm/pr42574.c: Require arm_thumb1_movt_ko instead of
         arm_thumb1_ok as effective target to exclude ARMv8-M Baseline.


diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index
47216b4a1959ccdb18e329db411bf7f941e67163..f42e996e5a7ce979fe406b8261d50fb2ba005f6b
100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -269,7 +269,7 @@ extern void (*arm_lang_output_object_attributes_hook)
(void);
  #define TARGET_HAVE_LDACQ     (TARGET_ARM_ARCH >= 8 && arm_arch_notm)
/* Nonzero if this chip provides the movw and movt instructions. */
-#define TARGET_HAVE_MOVT       (arm_arch_thumb2)
+#define TARGET_HAVE_MOVT       (arm_arch_thumb2 || arm_arch8)
/* Nonzero if integer division instructions supported. */
  #define TARGET_IDIV   ((TARGET_ARM && arm_arch_arm_hwdiv)     \
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index
d75a34f10d5ed22cff0a0b5d3ad433f111b059ee..13b4b71ac8f9c1da8ef1945f7ff6985ca59f6832
100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -8220,6 +8220,12 @@ arm_legitimate_constant_p_1 (machine_mode, rtx x)
  static bool
  thumb_legitimate_constant_p (machine_mode mode ATTRIBUTE_UNUSED, rtx x)
  {
+  /* Splitters for TARGET_USE_MOVT call arm_emit_movpair which creates high
+     RTX.  These RTX must therefore be allowed for Thumb-1 so that when run
+     for ARMv8-M baseline or later the result is valid.  */
+  if (TARGET_HAVE_MOVT && GET_CODE (x) == HIGH)
+    x = XEXP (x, 0);
+
    return (CONST_INT_P (x)
          || CONST_DOUBLE_P (x)
          || CONSTANT_ADDRESS_P (x)
@@ -8306,7 +8312,8 @@ thumb1_rtx_costs (rtx x, enum rtx_code code, enum
rtx_code outer)
      case CONST_INT:
        if (outer == SET)
        {
-         if ((unsigned HOST_WIDE_INT) INTVAL (x) < 256)
+         if ((unsigned HOST_WIDE_INT) INTVAL (x) < 256
+             || (TARGET_HAVE_MOVT && !(INTVAL (x) & 0xffff0000)))
            return 0;

Since you're modifying this line please replace (unsigned HOST_WIDE_INT) INTVAL 
(x)
with UINTVAL (x).

Reply via email to