public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][committed]middle-end: Fix addsub patch removing return statements
@ 2022-11-14 20:08 Tamar Christina
  0 siblings, 0 replies; only message in thread
From: Tamar Christina @ 2022-11-14 20:08 UTC (permalink / raw)
  To: gcc-patches; +Cc: nd, rguenther, jlaw

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

Hi All,

My recent patch had return statements in the match.pd expressions
which were recently outlawed.. Unfornately I didn't rebase this
patch before committing so this broke the build.

I've just reflowed the conditions to avoid the returns.

Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.

Committed to fix the build, but think it's still trivial as it just reflows the code.

Thanks,
Tamar

gcc/ChangeLog:

	* match.pd: Remove returns.

--- inline copy of patch -- 
diff --git a/gcc/match.pd b/gcc/match.pd
index 4701578c96451d56e5235d5e0bc5d0a0378c1435..946dcd1b301c8fbcfe36e534651ff0b183b324ef 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -7984,51 +7984,51 @@ and,
    {
      /* Build a vector of integers from the tree mask.  */
      vec_perm_builder builder;
-     if (!tree_to_vec_perm_builder (&builder, @2))
-       return NULL_TREE;
-
-     /* Create a vec_perm_indices for the integer vector.  */
-     poly_uint64 nelts = TYPE_VECTOR_SUBPARTS (type);
-     vec_perm_indices sel (builder, 2, nelts);
    }
-   (if (sel.series_p (0, 2, 0, 2))
+   (if (tree_to_vec_perm_builder (&builder, @2))
     (with
      {
+       /* Create a vec_perm_indices for the integer vector.  */
+       poly_uint64 nelts = TYPE_VECTOR_SUBPARTS (type);
+       vec_perm_indices sel (builder, 2, nelts);
        machine_mode vec_mode = TYPE_MODE (type);
        machine_mode wide_mode;
-       if (!GET_MODE_WIDER_MODE (vec_mode).exists (&wide_mode)
-	   || !VECTOR_MODE_P (wide_mode)
-	   || (GET_MODE_UNIT_BITSIZE (vec_mode) * 2
-		!= GET_MODE_UNIT_BITSIZE (wide_mode)))
-	 return NULL_TREE;
-
-       tree stype = lang_hooks.types.type_for_mode (GET_MODE_INNER (wide_mode),
-						    TYPE_UNSIGNED (type));
-       if (TYPE_MODE (stype) == BLKmode)
-	 return NULL_TREE;
-       tree ntype = build_vector_type_for_mode (stype, wide_mode);
-       if (!VECTOR_TYPE_P (ntype))
-	 return NULL_TREE;
-
-       /* The format has to be a non-extended ieee format.  */
-       const struct real_format *fmt_old = FLOAT_MODE_FORMAT (vec_mode);
-       const struct real_format *fmt_new = FLOAT_MODE_FORMAT (wide_mode);
-       if (fmt_old == NULL || fmt_new == NULL)
-	 return NULL_TREE;
-
-       /* If the target doesn't support v1xx vectors, try using scalar mode xx
-	  instead.  */
-       if (known_eq (GET_MODE_NUNITS (wide_mode), 1)
-	   && !target_supports_op_p (ntype, NEGATE_EXPR, optab_vector))
-	 ntype = stype;
      }
-     (if (fmt_new->signbit_rw
-	     == fmt_old->signbit_rw + GET_MODE_UNIT_BITSIZE (vec_mode)
-	  && fmt_new->signbit_rw == fmt_new->signbit_ro
-	  && targetm.can_change_mode_class (TYPE_MODE (ntype), TYPE_MODE (type), ALL_REGS)
-	  && ((optimize_vectors_before_lowering_p () && VECTOR_TYPE_P (ntype))
-	      || target_supports_op_p (ntype, NEGATE_EXPR, optab_vector)))
-      (plus (view_convert:type (negate (view_convert:ntype @1))) @0)))))))
+     (if (sel.series_p (0, 2, 0, 2)
+          && GET_MODE_WIDER_MODE (vec_mode).exists (&wide_mode)
+	  && VECTOR_MODE_P (wide_mode)
+	  && (GET_MODE_UNIT_BITSIZE (vec_mode) * 2
+	      == GET_MODE_UNIT_BITSIZE (wide_mode)))
+	(with
+	 {
+	   tree stype
+	     = lang_hooks.types.type_for_mode (GET_MODE_INNER (wide_mode),
+					       TYPE_UNSIGNED (type));
+	   tree ntype = build_vector_type_for_mode (stype, wide_mode);
+
+	   /* The format has to be a non-extended ieee format.  */
+	   const struct real_format *fmt_old = FLOAT_MODE_FORMAT (vec_mode);
+	   const struct real_format *fmt_new = FLOAT_MODE_FORMAT (wide_mode);
+	 }
+	 (if (TYPE_MODE (stype) != BLKmode
+	      && VECTOR_TYPE_P (ntype)
+	      && fmt_old != NULL
+	      && fmt_new != NULL)
+	  (with
+	   {
+	     /* If the target doesn't support v1xx vectors, try using
+		scalar mode xx instead.  */
+	    if (known_eq (GET_MODE_NUNITS (wide_mode), 1)
+		&& !target_supports_op_p (ntype, NEGATE_EXPR, optab_vector))
+	      ntype = stype;
+	   }
+	   (if (fmt_new->signbit_rw
+	        == fmt_old->signbit_rw + GET_MODE_UNIT_BITSIZE (vec_mode)
+		&& fmt_new->signbit_rw == fmt_new->signbit_ro
+		&& targetm.can_change_mode_class (TYPE_MODE (ntype), TYPE_MODE (type), ALL_REGS)
+		&& ((optimize_vectors_before_lowering_p () && VECTOR_TYPE_P (ntype))
+		    || target_supports_op_p (ntype, NEGATE_EXPR, optab_vector)))
+	    (plus (view_convert:type (negate (view_convert:ntype @1))) @0)))))))))))
 
 (simplify
  (vec_perm @0 @1 VECTOR_CST@2)




-- 

[-- Attachment #2: rb16594.patch --]
[-- Type: text/plain, Size: 3922 bytes --]

diff --git a/gcc/match.pd b/gcc/match.pd
index 4701578c96451d56e5235d5e0bc5d0a0378c1435..946dcd1b301c8fbcfe36e534651ff0b183b324ef 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -7984,51 +7984,51 @@ and,
    {
      /* Build a vector of integers from the tree mask.  */
      vec_perm_builder builder;
-     if (!tree_to_vec_perm_builder (&builder, @2))
-       return NULL_TREE;
-
-     /* Create a vec_perm_indices for the integer vector.  */
-     poly_uint64 nelts = TYPE_VECTOR_SUBPARTS (type);
-     vec_perm_indices sel (builder, 2, nelts);
    }
-   (if (sel.series_p (0, 2, 0, 2))
+   (if (tree_to_vec_perm_builder (&builder, @2))
     (with
      {
+       /* Create a vec_perm_indices for the integer vector.  */
+       poly_uint64 nelts = TYPE_VECTOR_SUBPARTS (type);
+       vec_perm_indices sel (builder, 2, nelts);
        machine_mode vec_mode = TYPE_MODE (type);
        machine_mode wide_mode;
-       if (!GET_MODE_WIDER_MODE (vec_mode).exists (&wide_mode)
-	   || !VECTOR_MODE_P (wide_mode)
-	   || (GET_MODE_UNIT_BITSIZE (vec_mode) * 2
-		!= GET_MODE_UNIT_BITSIZE (wide_mode)))
-	 return NULL_TREE;
-
-       tree stype = lang_hooks.types.type_for_mode (GET_MODE_INNER (wide_mode),
-						    TYPE_UNSIGNED (type));
-       if (TYPE_MODE (stype) == BLKmode)
-	 return NULL_TREE;
-       tree ntype = build_vector_type_for_mode (stype, wide_mode);
-       if (!VECTOR_TYPE_P (ntype))
-	 return NULL_TREE;
-
-       /* The format has to be a non-extended ieee format.  */
-       const struct real_format *fmt_old = FLOAT_MODE_FORMAT (vec_mode);
-       const struct real_format *fmt_new = FLOAT_MODE_FORMAT (wide_mode);
-       if (fmt_old == NULL || fmt_new == NULL)
-	 return NULL_TREE;
-
-       /* If the target doesn't support v1xx vectors, try using scalar mode xx
-	  instead.  */
-       if (known_eq (GET_MODE_NUNITS (wide_mode), 1)
-	   && !target_supports_op_p (ntype, NEGATE_EXPR, optab_vector))
-	 ntype = stype;
      }
-     (if (fmt_new->signbit_rw
-	     == fmt_old->signbit_rw + GET_MODE_UNIT_BITSIZE (vec_mode)
-	  && fmt_new->signbit_rw == fmt_new->signbit_ro
-	  && targetm.can_change_mode_class (TYPE_MODE (ntype), TYPE_MODE (type), ALL_REGS)
-	  && ((optimize_vectors_before_lowering_p () && VECTOR_TYPE_P (ntype))
-	      || target_supports_op_p (ntype, NEGATE_EXPR, optab_vector)))
-      (plus (view_convert:type (negate (view_convert:ntype @1))) @0)))))))
+     (if (sel.series_p (0, 2, 0, 2)
+          && GET_MODE_WIDER_MODE (vec_mode).exists (&wide_mode)
+	  && VECTOR_MODE_P (wide_mode)
+	  && (GET_MODE_UNIT_BITSIZE (vec_mode) * 2
+	      == GET_MODE_UNIT_BITSIZE (wide_mode)))
+	(with
+	 {
+	   tree stype
+	     = lang_hooks.types.type_for_mode (GET_MODE_INNER (wide_mode),
+					       TYPE_UNSIGNED (type));
+	   tree ntype = build_vector_type_for_mode (stype, wide_mode);
+
+	   /* The format has to be a non-extended ieee format.  */
+	   const struct real_format *fmt_old = FLOAT_MODE_FORMAT (vec_mode);
+	   const struct real_format *fmt_new = FLOAT_MODE_FORMAT (wide_mode);
+	 }
+	 (if (TYPE_MODE (stype) != BLKmode
+	      && VECTOR_TYPE_P (ntype)
+	      && fmt_old != NULL
+	      && fmt_new != NULL)
+	  (with
+	   {
+	     /* If the target doesn't support v1xx vectors, try using
+		scalar mode xx instead.  */
+	    if (known_eq (GET_MODE_NUNITS (wide_mode), 1)
+		&& !target_supports_op_p (ntype, NEGATE_EXPR, optab_vector))
+	      ntype = stype;
+	   }
+	   (if (fmt_new->signbit_rw
+	        == fmt_old->signbit_rw + GET_MODE_UNIT_BITSIZE (vec_mode)
+		&& fmt_new->signbit_rw == fmt_new->signbit_ro
+		&& targetm.can_change_mode_class (TYPE_MODE (ntype), TYPE_MODE (type), ALL_REGS)
+		&& ((optimize_vectors_before_lowering_p () && VECTOR_TYPE_P (ntype))
+		    || target_supports_op_p (ntype, NEGATE_EXPR, optab_vector)))
+	    (plus (view_convert:type (negate (view_convert:ntype @1))) @0)))))))))))
 
 (simplify
  (vec_perm @0 @1 VECTOR_CST@2)




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

only message in thread, other threads:[~2022-11-14 20:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-14 20:08 [PATCH][committed]middle-end: Fix addsub patch removing return statements Tamar Christina

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