public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@adacore.com>
To: Daniel Cederman <cederman@gaisler.com>
Cc: gcc-patches@gcc.gnu.org, sebastian.huber@embedded-brains.de,
	daniel@gaisler.com
Subject: Re: [PATCH v2 3/4] [SPARC] Errata workaround for GRLIB-TN-0010
Date: Mon, 04 Dec 2017 23:14:00 -0000	[thread overview]
Message-ID: <1649682.GIqfBrFdbj@polaris> (raw)
In-Reply-To: <4e11770c-3ab7-414a-3967-a077f262db64@gaisler.com>

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

> No, there was no particular reason. mem_ref seems like a better choice
> if it detects more types of loads.

Right, it's supposed to detect all types of loads.  Here's what I have 
installed on the mainline and 7 branch.


2017-12-04  Eric Botcazou  <ebotcazou@adacore.com>

	* config/sparc/sparc.c (sparc_do_work_around_errata): Use mem_ref
	instead of MEM_P in a couple more places.  Fix formatting issues.

-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 4182 bytes --]

Index: config/sparc/sparc.c
===================================================================
--- config/sparc/sparc.c	(revision 255291)
+++ config/sparc/sparc.c	(working copy)
@@ -1050,43 +1050,42 @@ sparc_do_work_around_errata (void)
       /* Look into the instruction in a delay slot.  */
       if (NONJUMP_INSN_P (insn)
 	  && (seq = dyn_cast <rtx_sequence *> (PATTERN (insn))))
-	  {
-	    jump = seq->insn (0);
-	    insn = seq->insn (1);
-	  }
+	{
+	  jump = seq->insn (0);
+	  insn = seq->insn (1);
+	}
       else if (JUMP_P (insn))
 	jump = insn;
       else
 	jump = NULL;
 
-      /* Place a NOP at the branch target of an integer branch if it is
-	 a floating-point operation or a floating-point branch.  */
+      /* Place a NOP at the branch target of an integer branch if it is a
+	 floating-point operation or a floating-point branch.  */
       if (sparc_fix_gr712rc
-	  && jump != NULL_RTX
+	  && jump
 	  && get_attr_branch_type (jump) == BRANCH_TYPE_ICC)
 	{
 	  rtx_insn *target = next_active_insn (JUMP_LABEL_AS_INSN (jump));
 	  if (target
 	      && (fpop_insn_p (target)
-		  || ((JUMP_P (target)
-		       && get_attr_branch_type (target) == BRANCH_TYPE_FCC))))
+		  || (JUMP_P (target)
+		      && get_attr_branch_type (target) == BRANCH_TYPE_FCC)))
 	    emit_insn_before (gen_nop (), target);
 	}
 
-      /* Insert a NOP between load instruction and atomic
-	 instruction.  Insert a NOP at branch target if load
-	 in delay slot and atomic instruction at branch target.  */
+      /* Insert a NOP between load instruction and atomic instruction.  Insert
+	 a NOP at branch target if there is a load in delay slot and an atomic
+	 instruction at branch target.  */
       if (sparc_fix_ut700
 	  && NONJUMP_INSN_P (insn)
 	  && (set = single_set (insn)) != NULL_RTX
-	  && MEM_P (SET_SRC (set))
+	  && mem_ref (SET_SRC (set))
 	  && REG_P (SET_DEST (set)))
 	{
 	  if (jump)
 	    {
 	      rtx_insn *target = next_active_insn (JUMP_LABEL_AS_INSN (jump));
-	      if (target
-		  && atomic_insn_for_leon3_p (target))
+	      if (target && atomic_insn_for_leon3_p (target))
 		emit_insn_before (gen_nop (), target);
 	    }
 
@@ -1098,7 +1097,9 @@ sparc_do_work_around_errata (void)
 	    insert_nop = true;
 	}
 
-      /* Look for sequences that could trigger the GRLIB-TN-0013 errata.  */
+      /* Look for a sequence that starts with a fdiv or fsqrt instruction and
+	 ends with another fdiv or fsqrt instruction with no dependencies on
+	 the former, along with an appropriate pattern in between.  */
       if (sparc_fix_lost_divsqrt
 	  && NONJUMP_INSN_P (insn)
 	  && div_sqrt_insn_p (insn))
@@ -1229,8 +1230,8 @@ sparc_do_work_around_errata (void)
 		 then the sequence cannot be problematic.  */
 	      if (i == 0)
 		{
-		  if (((set = single_set (after)) != NULL_RTX)
-		      && (MEM_P (SET_DEST (set)) || MEM_P (SET_SRC (set))))
+		  if ((set = single_set (after)) != NULL_RTX
+		      && (MEM_P (SET_DEST (set)) || mem_ref (SET_SRC (set))))
 		    break;
 
 		  after = next_active_insn (after);
@@ -1240,21 +1241,21 @@ sparc_do_work_around_errata (void)
 
 	      /* Add NOP if third instruction is a store.  */
 	      if (i == 1
-		  && ((set = single_set (after)) != NULL_RTX)
+		  && (set = single_set (after)) != NULL_RTX
 		  && MEM_P (SET_DEST (set)))
 		insert_nop = true;
 	    }
 	}
-      else
+
       /* Look for a single-word load into an odd-numbered FP register.  */
-      if (sparc_fix_at697f
-	  && NONJUMP_INSN_P (insn)
-	  && (set = single_set (insn)) != NULL_RTX
-	  && GET_MODE_SIZE (GET_MODE (SET_SRC (set))) == 4
-	  && MEM_P (SET_SRC (set))
-	  && REG_P (SET_DEST (set))
-	  && REGNO (SET_DEST (set)) > 31
-	  && REGNO (SET_DEST (set)) % 2 != 0)
+      else if (sparc_fix_at697f
+	       && NONJUMP_INSN_P (insn)
+	       && (set = single_set (insn)) != NULL_RTX
+	       && GET_MODE_SIZE (GET_MODE (SET_SRC (set))) == 4
+	       && mem_ref (SET_SRC (set))
+	       && REG_P (SET_DEST (set))
+	       && REGNO (SET_DEST (set)) > 31
+	       && REGNO (SET_DEST (set)) % 2 != 0)
 	{
 	  /* The wrong dependency is on the enclosing double register.  */
 	  const unsigned int x = REGNO (SET_DEST (set)) - 1;

  reply	other threads:[~2017-12-04 23:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-27  9:57 [PATCH v2 0/4] [SPARC] Workarounds for UT699, UT700, and GR712RC errata Daniel Cederman
2017-11-27  9:57 ` [PATCH v2 3/4] [SPARC] Errata workaround for GRLIB-TN-0010 Daniel Cederman
2017-11-28 10:04   ` Eric Botcazou
2017-12-04 11:06   ` Eric Botcazou
2017-12-04 12:25     ` Daniel Cederman
2017-12-04 23:14       ` Eric Botcazou [this message]
2017-11-27  9:57 ` [PATCH v2 2/4] [SPARC] Errata workaround for GRLIB-TN-0011 Daniel Cederman
2017-11-28 10:03   ` Eric Botcazou
2017-11-27 10:04 ` [PATCH v2 4/4] [SPARC] Errata workaround for GRLIB-TN-0013 Daniel Cederman
2017-11-27 16:43   ` Daniel Cederman
2017-11-28 10:08     ` Eric Botcazou
2017-11-28 10:05   ` Eric Botcazou
2017-11-27 10:04 ` [PATCH v2 1/4] [SPARC] Errata workaround for GRLIB-TN-0012 Daniel Cederman
2017-11-28 10:01   ` Eric Botcazou
2017-11-28 12:26     ` Daniel Cederman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1649682.GIqfBrFdbj@polaris \
    --to=ebotcazou@adacore.com \
    --cc=cederman@gaisler.com \
    --cc=daniel@gaisler.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=sebastian.huber@embedded-brains.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).