public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH v2] REE: PR rtl-optimization/100264: Handle more PARALLEL SET expressions
@ 2021-05-10 12:39 Christoph Muellner
  2021-06-02 21:04 ` Jim Wilson
  0 siblings, 1 reply; 2+ messages in thread
From: Christoph Muellner @ 2021-05-10 12:39 UTC (permalink / raw)
  To: gcc-patches, Jim Wilson, Jeff Law

Move the check for register targets (i.e. REG_P ()) into the function
get_sub_rtx () and change the restriction of REE to "only one child of
a PARALLEL expression is a SET register expression" (was "only one child of
a PARALLEL expression is a SET expression").

This allows to handle more PARALLEL SET expressions.

gcc/ChangeLog:
        PR rtl-optimization/100264
	* ree.c (get_sub_rtx): Ignore SET expressions without register
	destinations and remove assertion, as it is not valid anymore
	with this new behaviour.
	(merge_def_and_ext): Eliminate destination check for register
	as such SET expressions can't occur anymore.
	(combine_reaching_defs): Likewise.
---
 gcc/ree.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/gcc/ree.c b/gcc/ree.c
index 65457c582c6a..e31ca2fa1a80 100644
--- a/gcc/ree.c
+++ b/gcc/ree.c
@@ -658,10 +658,11 @@ make_defs_and_copies_lists (rtx_insn *extend_insn, const_rtx set_pat,
   return ret;
 }
 
-/* If DEF_INSN has single SET expression, possibly buried inside
-   a PARALLEL, return the address of the SET expression, else
-   return NULL.  This is similar to single_set, except that
-   single_set allows multiple SETs when all but one is dead.  */
+/* If DEF_INSN has single SET expression with a register
+   destination, possibly buried inside a PARALLEL, return
+   the address of the SET expression, else return NULL.
+   This is similar to single_set, except that single_set
+   allows multiple SETs when all but one is dead.  */
 static rtx *
 get_sub_rtx (rtx_insn *def_insn)
 {
@@ -675,6 +676,8 @@ get_sub_rtx (rtx_insn *def_insn)
           rtx s_expr = XVECEXP (PATTERN (def_insn), 0, i);
           if (GET_CODE (s_expr) != SET)
             continue;
+	  if (!REG_P (SET_DEST (s_expr)))
+	    continue;
 
           if (sub_rtx == NULL)
             sub_rtx = &XVECEXP (PATTERN (def_insn), 0, i);
@@ -686,14 +689,12 @@ get_sub_rtx (rtx_insn *def_insn)
         }
     }
   else if (code == SET)
-    sub_rtx = &PATTERN (def_insn);
-  else
     {
-      /* It is not a PARALLEL or a SET, what could it be ? */
-      return NULL;
+	rtx s_expr = PATTERN (def_insn);
+	if (REG_P (SET_DEST (s_expr)))
+	  sub_rtx = &PATTERN (def_insn);
     }
 
-  gcc_assert (sub_rtx != NULL);
   return sub_rtx;
 }
 
@@ -712,13 +713,12 @@ merge_def_and_ext (ext_cand *cand, rtx_insn *def_insn, ext_state *state)
   if (sub_rtx == NULL)
     return false;
 
-  if (REG_P (SET_DEST (*sub_rtx))
-      && (GET_MODE (SET_DEST (*sub_rtx)) == ext_src_mode
+  if (GET_MODE (SET_DEST (*sub_rtx)) == ext_src_mode
 	  || ((state->modified[INSN_UID (def_insn)].kind
 	       == (cand->code == ZERO_EXTEND
 		   ? EXT_MODIFIED_ZEXT : EXT_MODIFIED_SEXT))
 	      && state->modified[INSN_UID (def_insn)].mode
-		 == ext_src_mode)))
+		 == ext_src_mode))
     {
       if (GET_MODE_UNIT_SIZE (GET_MODE (SET_DEST (*sub_rtx)))
 	  >= GET_MODE_UNIT_SIZE (cand->mode))
@@ -853,8 +853,7 @@ combine_reaching_defs (ext_cand *cand, const_rtx set_pat, ext_state *state)
 	 CAND->insn, then this transformation is not safe.  Note we have
 	 to test in the widened mode.  */
       rtx *dest_sub_rtx = get_sub_rtx (def_insn);
-      if (dest_sub_rtx == NULL
-	  || !REG_P (SET_DEST (*dest_sub_rtx)))
+      if (dest_sub_rtx == NULL)
 	return false;
 
       rtx tmp_reg = gen_rtx_REG (GET_MODE (SET_DEST (set)),
@@ -947,8 +946,7 @@ combine_reaching_defs (ext_cand *cand, const_rtx set_pat, ext_state *state)
 	    break;
 
 	  rtx *dest_sub_rtx2 = get_sub_rtx (def_insn2);
-	  if (dest_sub_rtx2 == NULL
-	      || !REG_P (SET_DEST (*dest_sub_rtx2)))
+	  if (dest_sub_rtx2 == NULL)
 	    break;
 
 	  /* On RISC machines we must make sure that changing the mode of
-- 
2.31.1


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

* Re: [PATCH v2] REE: PR rtl-optimization/100264: Handle more PARALLEL SET expressions
  2021-05-10 12:39 [PATCH v2] REE: PR rtl-optimization/100264: Handle more PARALLEL SET expressions Christoph Muellner
@ 2021-06-02 21:04 ` Jim Wilson
  0 siblings, 0 replies; 2+ messages in thread
From: Jim Wilson @ 2021-06-02 21:04 UTC (permalink / raw)
  To: Christoph Muellner; +Cc: GCC Patches, Jeff Law

On Mon, May 10, 2021 at 5:39 AM Christoph Muellner <cmuellner@gcc.gnu.org>
wrote:

> gcc/ChangeLog:
>         PR rtl-optimization/100264
>         * ree.c (get_sub_rtx): Ignore SET expressions without register
>         destinations and remove assertion, as it is not valid anymore
>         with this new behaviour.
>         (merge_def_and_ext): Eliminate destination check for register
>         as such SET expressions can't occur anymore.
>         (combine_reaching_defs): Likewise.
>

The revised patch looks OK to me, and passed my testing.  I pushed it.

Jim

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

end of thread, other threads:[~2021-06-02 21:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10 12:39 [PATCH v2] REE: PR rtl-optimization/100264: Handle more PARALLEL SET expressions Christoph Muellner
2021-06-02 21:04 ` Jim Wilson

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