public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH]middle-end: Mark all control flow as used_in_scope.
@ 2023-12-11 10:22 Tamar Christina
  2023-12-11 10:43 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Tamar Christina @ 2023-12-11 10:22 UTC (permalink / raw)
  To: gcc-patches; +Cc: nd, rguenther, jlaw

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

Hi All,

While compiling SPECCPU 2017 I ran accross the reason (I had forgotten) why my
initial patch marked all control statements as used in scope and not just
gconds:  There are other statements that can introduce multiple exits, like
switch statements.   If we ignore them as not relevant we never get a chance to
reject them later as not vectorizable.  Becuase they are marked as not relevant
we crash or produce invalid code.

The fix is to mark all control statements as used in scope, and then we
later reject them as not vectorizable.

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

Ok for master?

Thanks,
Tamar

gcc/ChangeLog:

	* tree-vect-stmts.cc (vect_stmt_relevant_p): Mark all control flow as
	used in scope.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/vect-early-break_89.c: New test.

--- inline copy of patch -- 
diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_89.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_89.c
new file mode 100644
index 0000000000000000000000000000000000000000..d33f3d94c096ffc53e4e82a28c3db058633fb21d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_89.c
@@ -0,0 +1,18 @@
+/* { dg-require-effective-target vect_int } */
+
+char *a;
+extern void d();
+void b() {
+  int c = 0;
+  while (c < 16) {
+    switch (a[c]) {
+    case '"':
+    case '\'':
+      c++;
+      continue;
+    }
+    break;
+  }
+  if (c)
+    d();
+}
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 72f271658e357bd562eb29087735825eb5ab0dc0..98704b7cea8a93f5beae7a55c85085c049e54152 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -361,7 +361,7 @@ vect_stmt_relevant_p (stmt_vec_info stmt_info, loop_vec_info loop_vinfo,
 
   /* cond stmt other than loop exit cond.  */
   gimple *stmt = STMT_VINFO_STMT (stmt_info);
-  if (is_a <gcond *> (stmt)
+  if (is_ctrl_stmt (stmt)
       && LOOP_VINFO_LOOP_IV_COND (loop_vinfo) != stmt
       && (!loop->inner || gimple_bb (stmt)->loop_father == loop))
     *relevant = vect_used_in_scope;




-- 

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

diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_89.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_89.c
new file mode 100644
index 0000000000000000000000000000000000000000..d33f3d94c096ffc53e4e82a28c3db058633fb21d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_89.c
@@ -0,0 +1,18 @@
+/* { dg-require-effective-target vect_int } */
+
+char *a;
+extern void d();
+void b() {
+  int c = 0;
+  while (c < 16) {
+    switch (a[c]) {
+    case '"':
+    case '\'':
+      c++;
+      continue;
+    }
+    break;
+  }
+  if (c)
+    d();
+}
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 72f271658e357bd562eb29087735825eb5ab0dc0..98704b7cea8a93f5beae7a55c85085c049e54152 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -361,7 +361,7 @@ vect_stmt_relevant_p (stmt_vec_info stmt_info, loop_vec_info loop_vinfo,
 
   /* cond stmt other than loop exit cond.  */
   gimple *stmt = STMT_VINFO_STMT (stmt_info);
-  if (is_a <gcond *> (stmt)
+  if (is_ctrl_stmt (stmt)
       && LOOP_VINFO_LOOP_IV_COND (loop_vinfo) != stmt
       && (!loop->inner || gimple_bb (stmt)->loop_father == loop))
     *relevant = vect_used_in_scope;




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

* Re: [PATCH]middle-end: Mark all control flow as used_in_scope.
  2023-12-11 10:22 [PATCH]middle-end: Mark all control flow as used_in_scope Tamar Christina
@ 2023-12-11 10:43 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2023-12-11 10:43 UTC (permalink / raw)
  To: Tamar Christina; +Cc: gcc-patches, nd, jlaw

On Mon, 11 Dec 2023, Tamar Christina wrote:

> Hi All,
> 
> While compiling SPECCPU 2017 I ran accross the reason (I had forgotten) why my
> initial patch marked all control statements as used in scope and not just
> gconds:  There are other statements that can introduce multiple exits, like
> switch statements.   If we ignore them as not relevant we never get a chance to
> reject them later as not vectorizable.  Becuase they are marked as not relevant
> we crash or produce invalid code.
> 
> The fix is to mark all control statements as used in scope, and then we
> later reject them as not vectorizable.
> 
> Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.
> 
> Ok for master?

OK

> Thanks,
> Tamar
> 
> gcc/ChangeLog:
> 
> 	* tree-vect-stmts.cc (vect_stmt_relevant_p): Mark all control flow as
> 	used in scope.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* gcc.dg/vect/vect-early-break_89.c: New test.
> 
> --- inline copy of patch -- 
> diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_89.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_89.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..d33f3d94c096ffc53e4e82a28c3db058633fb21d
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_89.c
> @@ -0,0 +1,18 @@
> +/* { dg-require-effective-target vect_int } */
> +
> +char *a;
> +extern void d();
> +void b() {
> +  int c = 0;
> +  while (c < 16) {
> +    switch (a[c]) {
> +    case '"':
> +    case '\'':
> +      c++;
> +      continue;
> +    }
> +    break;
> +  }
> +  if (c)
> +    d();
> +}
> diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
> index 72f271658e357bd562eb29087735825eb5ab0dc0..98704b7cea8a93f5beae7a55c85085c049e54152 100644
> --- a/gcc/tree-vect-stmts.cc
> +++ b/gcc/tree-vect-stmts.cc
> @@ -361,7 +361,7 @@ vect_stmt_relevant_p (stmt_vec_info stmt_info, loop_vec_info loop_vinfo,
>  
>    /* cond stmt other than loop exit cond.  */
>    gimple *stmt = STMT_VINFO_STMT (stmt_info);
> -  if (is_a <gcond *> (stmt)
> +  if (is_ctrl_stmt (stmt)
>        && LOOP_VINFO_LOOP_IV_COND (loop_vinfo) != stmt
>        && (!loop->inner || gimple_bb (stmt)->loop_father == loop))
>      *relevant = vect_used_in_scope;
> 
> 
> 
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

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

end of thread, other threads:[~2023-12-11 10:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-11 10:22 [PATCH]middle-end: Mark all control flow as used_in_scope Tamar Christina
2023-12-11 10:43 ` Richard Biener

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