]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix memory constraint bug in SPARC back-end
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 12 Mar 2021 16:07:20 +0000 (17:07 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Fri, 12 Mar 2021 17:52:07 +0000 (18:52 +0100)
It's a bug exposed by the recent LRA changes, whereby the T constraint
fails to behave properly when LRA is enabled (unlike when reload is
enabled).  The patch also gets rid of the awkward W constraint, which
is strictly equivalent to m in 64-bit mode and, as a result, renames
the w constraint into W.

gcc/
PR target/99422
* config/sparc/constraints.md (w): Rename to...
(W): ... this and ditch previous implementation.
* config/sparc/sparc.md (*movdi_insn_sp64): Replace W with m.
(*movdf_insn_sp64): Likewise.
(*mov<VM64:mode>_insn_sp64): Likewise.
* config/sparc/sync.md (*atomic_compare_and_swap<mode>_1): Replace
w with W.
(atomic_compare_and_swap_leon3_1): Likewise.
(*atomic_compare_and_swapdi_v8plus): Likewise.
* config/sparc/sparc.c (memory_ok_for_ldd): Remove useless test on
architecture and add missing address validity check during LRA.

gcc/config/sparc/constraints.md
gcc/config/sparc/sparc.c
gcc/config/sparc/sparc.md
gcc/config/sparc/sync.md

index 82bbba90457fdf0fcff2a2918a62d3c488e21119..7ddf014596ddfd7c701a07d345b3f8e3879d2d37 100644 (file)
@@ -19,7 +19,7 @@
 
 ;;; Unused letters:
 ;;;     B
-;;;    a        jkl        uv xyz
+;;;    a        jkl        uvwxyz
 
 
 ;; Register constraints
       (match_test "TARGET_ARCH32")
       (match_test "register_ok_for_ldd (op)")))
 
-;; Equivalent to 'T' but in 64-bit mode without alignment requirement
 (define_memory_constraint "W"
- "Memory reference for 'e' constraint floating-point register"
- (and (match_code "mem")
-      (match_test "TARGET_ARCH64")
-      (match_test "memory_ok_for_ldd (op)")))
-
-(define_memory_constraint "w"
   "A memory with only a base register"
   (match_operand 0 "mem_noofs_operand"))
 
index f15041720223285a7e2183d1f5bdbaf2ee9bc82e..42ba415255c90abecb63e155b5575b2de2a976f3 100644 (file)
@@ -9223,14 +9223,17 @@ register_ok_for_ldd (rtx reg)
 int
 memory_ok_for_ldd (rtx op)
 {
-  /* In 64-bit mode, we assume that the address is word-aligned.  */
-  if (TARGET_ARCH32 && !mem_min_alignment (op, 8))
+  if (!mem_min_alignment (op, 8))
     return 0;
 
-  if (! can_create_pseudo_p ()
+  /* We need to perform the job of a memory constraint.  */
+  if ((reload_in_progress || reload_completed)
       && !strict_memory_address_p (Pmode, XEXP (op, 0)))
     return 0;
 
+  if (lra_in_progress && !memory_address_p (Pmode, XEXP (op, 0)))
+    return 0;
+
   return 1;
 }
 \f
index 02b7c8d2fdd7b1e7f8a8ed5111323f8196fc593c..c5d369626cc5232e7e1da7fbb271c24f16f8b84e 100644 (file)
@@ -1869,8 +1869,8 @@ visl")
    (set_attr "lra" "*,*,disabled,disabled,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*")])
 
 (define_insn "*movdi_insn_sp64"
-  [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r, m, r,*e,?*e,?*e,  W,b,b")
-        (match_operand:DI 1 "input_operand"        "rI,N,m,rJ,*e, r, *e,  W,?*e,J,P"))]
+  [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r, m, r,*e,?*e,?*e,  m,b,b")
+        (match_operand:DI 1 "input_operand"        "rI,N,m,rJ,*e, r, *e,  m,?*e,J,P"))]
   "TARGET_ARCH64
    && (register_operand (operands[0], DImode)
        || register_or_zero_or_all_ones_operand (operands[1], DImode))"
@@ -2498,8 +2498,8 @@ visl")
    (set_attr "lra" "*,*,*,*,*,*,*,*,*,*,disabled,disabled,*,*,*,*,*")])
 
 (define_insn "*movdf_insn_sp64"
-  [(set (match_operand:DF 0 "nonimmediate_operand" "=b,b,e,*r, e,  e,W, *r,*r,  m,*r")
-       (match_operand:DF 1 "input_operand"         "G,C,e, e,*r,W#F,e,*rG, m,*rG, F"))]
+  [(set (match_operand:DF 0 "nonimmediate_operand" "=b,b,e,*r, e,  e,m, *r,*r,  m,*r")
+       (match_operand:DF 1 "input_operand"         "G,C,e, e,*r,m#F,e,*rG, m,*rG, F"))]
   "TARGET_ARCH64
    && (register_operand (operands[0], DFmode)
        || register_or_zero_or_all_ones_operand (operands[1], DFmode))"
@@ -8467,8 +8467,8 @@ visl")
    (set_attr "cpu_feature" "vis,vis,vis,*,*,*,*,*,*,vis3,vis3")])
 
 (define_insn "*mov<VM64:mode>_insn_sp64"
-  [(set (match_operand:VM64 0 "nonimmediate_operand" "=e,e,e,e,W,m,*r, m,*r, e,*r")
-       (match_operand:VM64 1 "input_operand"         "Y,Z,e,W,e,Y, m,*r, e,*r,*r"))]
+  [(set (match_operand:VM64 0 "nonimmediate_operand" "=e,e,e,e,m,m,*r, m,*r, e,*r")
+       (match_operand:VM64 1 "input_operand"         "Y,Z,e,m,e,Y, m,*r, e,*r,*r"))]
   "TARGET_VIS
    && TARGET_ARCH64
    && (register_operand (operands[0], <VM64:MODE>mode)
index c578e95811ec97e39b9b20374828c5c5c72289e7..c0a20ef8937009e3a69c1276c4dd35ced110f3ef 100644 (file)
 
 (define_insn "*atomic_compare_and_swap<mode>_1"
   [(set (match_operand:I48MODE 0 "register_operand" "=r")
-       (match_operand:I48MODE 1 "mem_noofs_operand" "+w"))
+       (match_operand:I48MODE 1 "mem_noofs_operand" "+W"))
    (set (match_dup 1)
        (unspec_volatile:I48MODE
          [(match_operand:I48MODE 2 "register_operand" "r")
 
 (define_insn "atomic_compare_and_swap_leon3_1"
   [(set (match_operand:SI 0 "register_operand" "=r")
-       (match_operand:SI 1 "mem_noofs_operand" "+w"))
+       (match_operand:SI 1 "mem_noofs_operand" "+W"))
    (set (match_dup 1)
        (unspec_volatile:SI
          [(match_operand:SI 2 "register_operand" "r")
 
 (define_insn "*atomic_compare_and_swapdi_v8plus"
   [(set (match_operand:DI 0 "register_operand" "=h")
-       (match_operand:DI 1 "mem_noofs_operand" "+w"))
+       (match_operand:DI 1 "mem_noofs_operand" "+W"))
    (set (match_dup 1)
        (unspec_volatile:DI
          [(match_operand:DI 2 "register_operand" "h")