On 9/12/24 08:14, Stefan Schulze Frielinghaus wrote:
..
Right, so offsettable_memref_p only ensures that any resulting
address is a
valid general address.  So we have to manually check for short
displacement.
Maybe something along the lines:

diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc
index 7aea776da2f..e61cda8352a 100644
--- a/gcc/config/s390/s390.cc
+++ b/gcc/config/s390/s390.cc
@@ -3714,6 +3714,18 @@ s390_mem_constraint (const char *str, rtx op)
        if ((reload_completed || reload_in_progress)
           ? !offsettable_memref_p (op) :
!offsettable_nonstrict_memref_p (op))
         return 0;
+      /* offsettable_memref_p ensures only that any positive offset
added to
+        the address forms a valid general address.  For Q and R
constraints we
+        also have to verify that the resulting displacement after
adding any
+        positive offset less than the size of the object being
referenced is
+        still valid.  */
+      if (str[1] == 'Q' || str[1] == 'R')
+       {
+         int o = GET_MODE_SIZE (GET_MODE (op)) - 1;
+         rtx tmp = adjust_address (op, QImode, o);
+         if (!s390_check_qrst_address (str[1], XEXP (tmp, 0), true))
+           return 0;
+       }
        return s390_check_qrst_address (str[1], XEXP (op, 0), true);
      case 'B':
        /* Check for non-literal-pool variants of memory constraints.
*/

My reading of the constraints A[RQST] is that those are only used for
operands
with non-block mode.  Thus, I didn't check for block mode.  Maybe an
assert
would be worthwhile.
This looks reasonable to me. I guess this deserves to be a separate
patch?
Yea I think so, too, since this fixes the constraints AR and AQ which is
independent of this patch.  I will prepare one shortly.

Agreed. Feel free to commit the change above right away. Thanks!

Andreas

Reply via email to