public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] xtensa: Revise 89afb2e86fcb29c559b2957fdcbea0d01740c49b
       [not found] <28f483f8-3ace-2150-3352-886a11a9e514.ref@yahoo.co.jp>
@ 2023-01-20  3:33 ` Takayuki 'January June' Suwa
  2023-01-24 21:25   ` Max Filippov
  0 siblings, 1 reply; 2+ messages in thread
From: Takayuki 'January June' Suwa @ 2023-01-20  3:33 UTC (permalink / raw)
  To: GCC Patches; +Cc: Max Filippov

In the previously posted patch
"xtensa: Make complex hard register clobber elimination more robust and accurate",
the check code for insns that refer to the [DS]Cmode hard register before
it is overwritten after it is clobbered is incomplete.  Fortunately such
insns are seldom emitted, so it didn't matter.

This patch fixes that for the sake of completeness.

gcc/ChangeLog:

	* config/xtensa/xtensa.md:
	Fix exit from loops detecting references before overwriting in the
	split pattern.
---
 gcc/config/xtensa/xtensa.md | 72 +++++++++++++++++++------------------
 1 file changed, 37 insertions(+), 35 deletions(-)

diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md
index 8432d7bcb..e26772413 100644
--- a/gcc/config/xtensa/xtensa.md
+++ b/gcc/config/xtensa/xtensa.md
@@ -2976,45 +2976,47 @@
 {
   auto_sbitmap bmp (FIRST_PSEUDO_REGISTER);
   rtx_insn *insn;
-  rtx reg = gen_rtx_REG (SImode, 0);
+  rtx reg = gen_rtx_REG (SImode, 0), dest;
+  unsigned int regno;
+  sbitmap_iterator iter;
   bitmap_set_range (bmp, REGNO (operands[0]), REG_NREGS (operands[0]));
   for (insn = next_nonnote_nondebug_insn_bb (curr_insn);
        insn; insn = next_nonnote_nondebug_insn_bb (insn))
-    {
-      sbitmap_iterator iter;
-      unsigned int regno;
-      if (NONJUMP_INSN_P (insn))
-	{
-	  EXECUTE_IF_SET_IN_BITMAP (bmp, 2, regno, iter)
-	    {
-	      set_regno_raw (reg, regno, REG_NREGS (reg));
-	      if (reg_overlap_mentioned_p (reg, PATTERN (insn)))
-		break;
-	    }
-	  if (GET_CODE (PATTERN (insn)) == SET)
-	    {
-	      rtx x = SET_DEST (PATTERN (insn));
-	      if (REG_P (x) && HARD_REGISTER_P (x))
-		bitmap_clear_range (bmp, REGNO (x), REG_NREGS (x));
-	      else if (SUBREG_P (x) && HARD_REGISTER_P (SUBREG_REG (x)))
-		{
-		  struct subreg_info info;
-		  subreg_get_info (regno = REGNO (SUBREG_REG (x)),
-				   GET_MODE (SUBREG_REG (x)),
-				   SUBREG_BYTE (x), GET_MODE (x), &info);
-		  if (!info.representable_p)
-		    break;
-		  bitmap_clear_range (bmp, regno + info.offset, info.nregs);
-		}
-	    }
-	  if (bitmap_empty_p (bmp))
-	    goto FALLTHRU;
-	}
-      else if (CALL_P (insn))
+    if (NONJUMP_INSN_P (insn))
+      {
 	EXECUTE_IF_SET_IN_BITMAP (bmp, 2, regno, iter)
-	 if (call_used_or_fixed_reg_p (regno))
-	   break;
-    }
+	  {
+	    set_regno_raw (reg, regno, REG_NREGS (reg));
+	    if (reg_referenced_p (reg, PATTERN (insn)))
+	      goto ABORT;
+	  }
+	if (GET_CODE (PATTERN (insn)) == SET
+	    || GET_CODE (PATTERN (insn)) == CLOBBER)
+	  {
+	    dest = SET_DEST (PATTERN (insn));
+	    if (REG_P (dest) && HARD_REGISTER_P (dest))
+	      bitmap_clear_range (bmp, REGNO (dest), REG_NREGS (dest));
+	    else if (SUBREG_P (dest)
+		     && HARD_REGISTER_P (SUBREG_REG (dest)))
+	      {
+		struct subreg_info info;
+		subreg_get_info (regno = REGNO (SUBREG_REG (dest)),
+				 GET_MODE (SUBREG_REG (dest)),
+				 SUBREG_BYTE (dest), GET_MODE (dest),
+				 &info);
+		if (!info.representable_p)
+		  break;
+		bitmap_clear_range (bmp, regno + info.offset, info.nregs);
+	      }
+	  }
+	if (bitmap_empty_p (bmp))
+	  goto FALLTHRU;
+      }
+    else if (CALL_P (insn))
+      EXECUTE_IF_SET_IN_BITMAP (bmp, 2, regno, iter)
+	if (call_used_or_fixed_reg_p (regno))
+	  goto ABORT;
+ABORT:
   FAIL;
 FALLTHRU:;
 })
-- 
2.30.2

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] xtensa: Revise 89afb2e86fcb29c559b2957fdcbea0d01740c49b
  2023-01-20  3:33 ` [PATCH] xtensa: Revise 89afb2e86fcb29c559b2957fdcbea0d01740c49b Takayuki 'January June' Suwa
@ 2023-01-24 21:25   ` Max Filippov
  0 siblings, 0 replies; 2+ messages in thread
From: Max Filippov @ 2023-01-24 21:25 UTC (permalink / raw)
  To: Takayuki 'January June' Suwa; +Cc: GCC Patches

On Thu, Jan 19, 2023 at 7:33 PM Takayuki 'January June' Suwa
<jjsuwa_sys3175@yahoo.co.jp> wrote:
>
> In the previously posted patch
> "xtensa: Make complex hard register clobber elimination more robust and accurate",
> the check code for insns that refer to the [DS]Cmode hard register before
> it is overwritten after it is clobbered is incomplete.  Fortunately such
> insns are seldom emitted, so it didn't matter.
>
> This patch fixes that for the sake of completeness.
>
> gcc/ChangeLog:
>
>         * config/xtensa/xtensa.md:
>         Fix exit from loops detecting references before overwriting in the
>         split pattern.
> ---
>  gcc/config/xtensa/xtensa.md | 72 +++++++++++++++++++------------------
>  1 file changed, 37 insertions(+), 35 deletions(-)

Regtested for target=xtensa-linux-uclibc, no new regressions.
Committed to master with more human readable subject line.

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-24 21:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <28f483f8-3ace-2150-3352-886a11a9e514.ref@yahoo.co.jp>
2023-01-20  3:33 ` [PATCH] xtensa: Revise 89afb2e86fcb29c559b2957fdcbea0d01740c49b Takayuki 'January June' Suwa
2023-01-24 21:25   ` Max Filippov

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).