diff mbox series

[ARC,ZOL] Account for empty body loops

Message ID 1504269130-29760-1-git-send-email-claziss@synopsys.com
State New
Headers show
Series [ARC,ZOL] Account for empty body loops | expand

Commit Message

Claudiu Zissulescu Sept. 1, 2017, 12:32 p.m. UTC
From: claziss <claziss@synopsys.com>

Hi Andrew,

By mistake I've pushed an incoplete ZOL-rework patch, and it missing the attached parts. Please can you check if it is ok?

Thank you,
Claudiu

gcc/
2017-09-01  Claudiu Zissulescu <claziss@synopsys.com>

	    * config/arc/arc.c (hwloop_optimize): Account for empty
	    body loops.

testsuite/
2017-09-01  Claudiu Zissulescu <claziss@synopsys.com>

 	        * gcc.target/arc/loop-1.c: Add test.
---
 gcc/config/arc/arc.c                  | 13 +++++++++++--
 gcc/testsuite/gcc.target/arc/loop-1.c | 12 ++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)
 create mode 100755 gcc/testsuite/gcc.target/arc/loop-1.c

Comments

Andrew Burgess Sept. 26, 2017, 6:56 p.m. UTC | #1
* Claudiu Zissulescu <Claudiu.Zissulescu@synopsys.com> [2017-09-01 14:32:10 +0200]:

> From: claziss <claziss@synopsys.com>
> 
> Hi Andrew,
> 
> By mistake I've pushed an incoplete ZOL-rework patch, and it missing the attached parts. Please can you check if it is ok?
> 
> Thank you,
> Claudiu
> 
> gcc/
> 2017-09-01  Claudiu Zissulescu <claziss@synopsys.com>
> 
> 	    * config/arc/arc.c (hwloop_optimize): Account for empty
> 	    body loops.

Looks good to me.

Thanks,
Andrew


> 
> testsuite/
> 2017-09-01  Claudiu Zissulescu <claziss@synopsys.com>
> 
>  	        * gcc.target/arc/loop-1.c: Add test.
> ---
>  gcc/config/arc/arc.c                  | 13 +++++++++++--
>  gcc/testsuite/gcc.target/arc/loop-1.c | 12 ++++++++++++
>  2 files changed, 23 insertions(+), 2 deletions(-)
>  create mode 100755 gcc/testsuite/gcc.target/arc/loop-1.c
> 
> diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
> index 52a9b24..d519063 100644
> --- a/gcc/config/arc/arc.c
> +++ b/gcc/config/arc/arc.c
> @@ -7240,6 +7240,12 @@ hwloop_optimize (hwloop_info loop)
>  	fprintf (dump_file, ";; loop %d too long\n", loop->loop_no);
>        return false;
>      }
> +  else if (!loop->length)
> +    {
> +      if (dump_file)
> +	fprintf (dump_file, ";; loop %d is empty\n", loop->loop_no);
> +      return false;
> +    }
>  
>    /* Check if we use a register or not.  */
>    if (!REG_P (loop->iter_reg))
> @@ -7311,8 +7317,11 @@ hwloop_optimize (hwloop_info loop)
>        && INSN_P (last_insn)
>        && (JUMP_P (last_insn) || CALL_P (last_insn)
>  	  || GET_CODE (PATTERN (last_insn)) == SEQUENCE
> -	  || get_attr_type (last_insn) == TYPE_BRCC
> -	  || get_attr_type (last_insn) == TYPE_BRCC_NO_DELAY_SLOT))
> +	  /* At this stage we can have (insn (clobber (mem:BLK
> +	     (reg)))) instructions, ignore them.  */
> +	  || (GET_CODE (PATTERN (last_insn)) != CLOBBER
> +	      && (get_attr_type (last_insn) == TYPE_BRCC
> +		  || get_attr_type (last_insn) == TYPE_BRCC_NO_DELAY_SLOT))))
>      {
>        if (loop->length + 2 > ARC_MAX_LOOP_LENGTH)
>  	{
> diff --git a/gcc/testsuite/gcc.target/arc/loop-1.c b/gcc/testsuite/gcc.target/arc/loop-1.c
> new file mode 100755
> index 0000000..274bb46
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/arc/loop-1.c
> @@ -0,0 +1,12 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +
> +/* Check how we handle empty body loops.  */
> +
> +int a;
> +void fn1(void) {
> +  int i;
> +  for (; i < 8; i++) {
> +    double A[a];
> +  }
> +}
> -- 
> 1.9.1
>
Claudiu Zissulescu Nov. 2, 2017, 10:20 a.m. UTC | #2
> > gcc/
> > 2017-09-01  Claudiu Zissulescu <claziss@synopsys.com>
> >
> > 	    * config/arc/arc.c (hwloop_optimize): Account for empty
> > 	    body loops.
> 
> Looks good to me.
> 
> Thanks,
> Andrew
> 
> 

Pushed. Thank you for your review,
Claudiu
diff mbox series

Patch

diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index 52a9b24..d519063 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -7240,6 +7240,12 @@  hwloop_optimize (hwloop_info loop)
 	fprintf (dump_file, ";; loop %d too long\n", loop->loop_no);
       return false;
     }
+  else if (!loop->length)
+    {
+      if (dump_file)
+	fprintf (dump_file, ";; loop %d is empty\n", loop->loop_no);
+      return false;
+    }
 
   /* Check if we use a register or not.  */
   if (!REG_P (loop->iter_reg))
@@ -7311,8 +7317,11 @@  hwloop_optimize (hwloop_info loop)
       && INSN_P (last_insn)
       && (JUMP_P (last_insn) || CALL_P (last_insn)
 	  || GET_CODE (PATTERN (last_insn)) == SEQUENCE
-	  || get_attr_type (last_insn) == TYPE_BRCC
-	  || get_attr_type (last_insn) == TYPE_BRCC_NO_DELAY_SLOT))
+	  /* At this stage we can have (insn (clobber (mem:BLK
+	     (reg)))) instructions, ignore them.  */
+	  || (GET_CODE (PATTERN (last_insn)) != CLOBBER
+	      && (get_attr_type (last_insn) == TYPE_BRCC
+		  || get_attr_type (last_insn) == TYPE_BRCC_NO_DELAY_SLOT))))
     {
       if (loop->length + 2 > ARC_MAX_LOOP_LENGTH)
 	{
diff --git a/gcc/testsuite/gcc.target/arc/loop-1.c b/gcc/testsuite/gcc.target/arc/loop-1.c
new file mode 100755
index 0000000..274bb46
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/loop-1.c
@@ -0,0 +1,12 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+/* Check how we handle empty body loops.  */
+
+int a;
+void fn1(void) {
+  int i;
+  for (; i < 8; i++) {
+    double A[a];
+  }
+}