public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] [PR99663] Don't use unknown constraint for address constraint in process_address_1.
@ 2021-03-19 19:40 Vladimir Makarov
  0 siblings, 0 replies; only message in thread
From: Vladimir Makarov @ 2021-03-19 19:40 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 143 bytes --]

The following patch solves

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99663

The patch was successfully bootstrapped and tested on x86-64.


[-- Attachment #2: pr99663.c --]
[-- Type: text/x-csrc, Size: 2852 bytes --]

commit d81019db099ad95febbb2d4b4afd8cbe95762062
Author: Vladimir N. Makarov <vmakarov@redhat.com>
Date:   Fri Mar 19 15:34:48 2021 -0400

    [PR99663] Don't use unknown constraint for address constraint in process_address_1.
    
    s390x has insns using several alternatives with address constraints.  Even
    if we don't know at this stage what alternative will be used, we still can say
    that is an address constraint.  So don't use unknown constraint in this
    case when there are multiple constraints or/and alternative.
    
    gcc/ChangeLog:
    
            PR target/99663
            * lra-constraints.c (process_address_1): Don't use unknown
            constraint for address constraint.
    
    gcc/testsuite/ChangeLog:
    
            PR target/99663
            * gcc.target/s390/pr99663.c: New.

diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index 64801b6fcce..698d8d04a1e 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -3459,12 +3459,17 @@ process_address_1 (int nop, bool check_only_p,
       constraint
 	= skip_contraint_modifiers (curr_static_id->operand[dup].constraint);
     }
-  if (*skip_contraint_modifiers (constraint
-				 + CONSTRAINT_LEN (constraint[0],
-						   constraint)) != '\0')
+  cn = lookup_constraint (*constraint == '\0' ? "X" : constraint);
+  /* If we have several alternatives or/and several constraints in an
+     alternative and we can not say at this stage what constraint will be used,
+     use unknown constraint.  The exception is an address constraint.  If
+     operand has one address constraint, probably all others constraints are
+     address ones.  */
+  if (get_constraint_type (cn) != CT_ADDRESS
+      && *skip_contraint_modifiers (constraint
+				    + CONSTRAINT_LEN (constraint[0],
+						      constraint)) != '\0')
     cn = CONSTRAINT__UNKNOWN;
-  else
-    cn = lookup_constraint (*constraint == '\0' ? "X" : constraint);
   if (insn_extra_address_constraint (cn)
       /* When we find an asm operand with an address constraint that
 	 doesn't satisfy address_operand to begin with, we clear
diff --git a/gcc/testsuite/gcc.target/s390/pr99663.c b/gcc/testsuite/gcc.target/s390/pr99663.c
new file mode 100644
index 00000000000..f4f0f94a63a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/pr99663.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-mtune=z15 -march=z13 -mzarch -O2 -fno-stack-protector -fPIC" } */
+
+typedef struct {
+  int exponent;
+  unsigned short lsu[];
+} decNumber;
+decNumber decDivideOp_lhs;
+short decDivideOp_varbuff;
+void decDivideOp(decNumber *rhs) {
+  short *msu1;
+  int exponent;
+  unsigned short *source;
+  for (; source >= decDivideOp_lhs.lsu; source--, msu1--)
+    *msu1 = *source;
+  for (;;)
+    if (exponent)
+      if (decDivideOp_varbuff)
+        exponent = rhs->exponent;
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-19 19:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19 19:40 [COMMITTED] [PR99663] Don't use unknown constraint for address constraint in process_address_1 Vladimir Makarov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).