This patch splits up the macros SIGNED_16BIT_OFFSET_P and SIGNED_34BIT_OFFSET_P
into two separate macros as you asked for previously in private mail.  The main
macros:

        SIGNED_16BIT_OFFSET_P
        SIGNED_34BIT_OFFSET_P

only take one argument, and that is the offset that is being tested.  The new
macros:

        SIGNED_16BIT_OFFSET_EXTRA_P
        SIGNED_34BIT_OFFSET_EXTRA_P

Retain the two arguments that the current macros have.  It is useful when the
functions that are validating addresses that might be split (such as the two
doubles in __ibm128) to verify that all addresses in the range of offset to
offset + extra are valid 16 or 34-bit offsets.  I have changed the existing
uses of these macros.

I have bootstrapped the compiler on a little endian power8 machine and there
were no regressions in the test suite.  Can I check this change into the trunk?

2019-07-09  Michael Meissner  <meiss...@linux.ibm.com>

        * config/rs6000/predicates.md (cint34_operand): Update
        SIGNED_34BIT_OFFSET_P call.
        (pcrel_address): Update SIGNED_34BIT_OFFSET_P call.
        (pcrel_external_address): Update SIGNED_34BIT_OFFSET_P call.
        * config/rs6000/rs6000.c (rs6000_prefixed_address): Update
        SIGNED_16BIT_OFFSET_P and SIGNED_34BIT_OFFSET_P calls.
        * config/rs6000/rs6000.h (SIGNED_16BIT_OFFSET_P): Remove EXTRA
        argument.
        (SIGNED_34BIT_OFFSET_P): Remove EXTRA argument.
        (SIGNED_16BIT_OFFSET_EXTRA_P): New macro, like
        SIGNED_16BIT_OFFSET_P with an EXTRA argument.
        (SIGNED_34BIT_OFFSET_EXTRA_P): New macro, like
        SIGNED_34BIT_OFFSET_P with an EXTRA argument.

Index: gcc/config/rs6000/predicates.md
===================================================================
--- gcc/config/rs6000/predicates.md     (revision 273255)
+++ gcc/config/rs6000/predicates.md     (working copy)
@@ -309,7 +309,7 @@ (define_predicate "cint34_operand"
   if (!TARGET_PREFIXED_ADDR)
     return 0;
 
-  return SIGNED_34BIT_OFFSET_P (INTVAL (op), 0);
+  return SIGNED_34BIT_OFFSET_P (INTVAL (op));
 })
 
 ;; Return 1 if op is a register that is not special.
@@ -1638,7 +1638,7 @@ (define_predicate "pcrel_address"
       rtx op0 = XEXP (op, 0);
       rtx op1 = XEXP (op, 1);
 
-      if (!CONST_INT_P (op1) || !SIGNED_34BIT_OFFSET_P (INTVAL (op1), 0))
+      if (!CONST_INT_P (op1) || !SIGNED_34BIT_OFFSET_P (INTVAL (op1)))
        return false;
 
       op = op0;
@@ -1673,7 +1673,7 @@ (define_predicate "pcrel_external_addres
       rtx op0 = XEXP (op, 0);
       rtx op1 = XEXP (op, 1);
 
-      if (!CONST_INT_P (op1) || !SIGNED_34BIT_OFFSET_P (INTVAL (op1), 0))
+      if (!CONST_INT_P (op1) || !SIGNED_34BIT_OFFSET_P (INTVAL (op1)))
        return false;
 
       op = op0;
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c  (revision 273313)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -21551,11 +21551,11 @@ rs6000_prefixed_address (rtx addr, machi
        return false;
 
       HOST_WIDE_INT value = INTVAL (op1);
-      if (!SIGNED_34BIT_OFFSET_P (value, 0))
+      if (!SIGNED_34BIT_OFFSET_P (value))
        return false;
 
       /* Offset larger than 16-bits?  */
-      if (!SIGNED_16BIT_OFFSET_P (value, 0))
+      if (!SIGNED_16BIT_OFFSET_P (value))
        return true;
 
       /* DQ instruction (bottom 4 bits must be 0) for vectors.  */
Index: gcc/config/rs6000/rs6000.h
===================================================================
--- gcc/config/rs6000/rs6000.h  (revision 273255)
+++ gcc/config/rs6000/rs6000.h  (working copy)
@@ -2526,16 +2526,27 @@ typedef struct GTY(()) machine_function
 #pragma GCC poison TARGET_FLOAT128 OPTION_MASK_FLOAT128 MASK_FLOAT128
 #endif
 
-/* Whether a given VALUE is a valid 16- or 34-bit signed offset.  EXTRA is the
-   amount that we can't touch at the high end of the range (typically if the
-   address is split into smaller addresses, the extra covers the addresses
-   which might be generated when the insn is split).  */
-#define SIGNED_16BIT_OFFSET_P(VALUE, EXTRA)                            \
-  IN_RANGE (VALUE,                                                     \
+/* Whether a given VALUE is a valid 16 or 34-bit signed offset.  */
+#define SIGNED_16BIT_OFFSET_P(VALUE)                                   \
+  IN_RANGE ((VALUE),                                                   \
+           -(HOST_WIDE_INT_1 << 15),                                   \
+           (HOST_WIDE_INT_1 << 15) - 1)
+
+#define SIGNED_34BIT_OFFSET_P(VALUE)                                   \
+  IN_RANGE ((VALUE),                                                   \
+           -(HOST_WIDE_INT_1 << 33),                                   \
+           (HOST_WIDE_INT_1 << 33) - 1)
+
+/* Like SIGNED_16BIT_OFFSET_P and SIGNED_34BIT_OFFSET_P, but with an extra
+   argument that gives a length to validate a range of addresses, to allow for
+   splitting insns into several insns, each of which has an offsettable
+   address.  */
+#define SIGNED_16BIT_OFFSET_EXTRA_P(VALUE, EXTRA)                      \
+  IN_RANGE ((VALUE),                                                   \
            -(HOST_WIDE_INT_1 << 15),                                   \
            (HOST_WIDE_INT_1 << 15) - 1 - (EXTRA))
 
-#define SIGNED_34BIT_OFFSET_P(VALUE, EXTRA)                            \
-  IN_RANGE (VALUE,                                                     \
+#define SIGNED_34BIT_OFFSET_EXTRA_P(VALUE, EXTRA)                      \
+  IN_RANGE ((VALUE),                                                   \
            -(HOST_WIDE_INT_1 << 33),                                   \
            (HOST_WIDE_INT_1 << 33) - 1 - (EXTRA))


-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.ibm.com, phone: +1 (978) 899-4797

Reply via email to