[ARC][ZOL] Account for empty body loops
authorClaudiu Zissulescu <claziss@synopsys.com>
Thu, 2 Nov 2017 10:20:18 +0000 (11:20 +0100)
committerClaudiu Zissulescu <claziss@gcc.gnu.org>
Thu, 2 Nov 2017 10:20:18 +0000 (11:20 +0100)
gcc/
2017-11-02  Claudiu Zissulescu <claziss@synopsys.com>

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

testsuite/
2017-11-02  Claudiu Zissulescu <claziss@synopsys.com>

      * gcc.target/arc/loop-1.c: Add test.

From-SVN: r254339

gcc/ChangeLog
gcc/config/arc/arc.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arc/loop-1.c [new file with mode: 0755]

index fc871f8..d80fa53 100644 (file)
@@ -1,3 +1,8 @@
+2017-11-02  Claudiu Zissulescu <claziss@synopsys.com>
+
+       * config/arc/arc.c (hwloop_optimize): Account for empty
+       body loops.
+
 2017-11-02  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/82765
index a0b6675..7336fad 100644 (file)
@@ -7183,6 +7183,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))
@@ -7254,8 +7260,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)
        {
index c951510..a8bb8ca 100644 (file)
@@ -1,3 +1,7 @@
+2017-11-02  Claudiu Zissulescu <claziss@synopsys.com>
+
+       * gcc.target/arc/loop-1.c: Add test.
+
 2017-11-02  Tom de Vries  <tom@codesourcery.com>
 
        PR testsuite/82415
diff --git a/gcc/testsuite/gcc.target/arc/loop-1.c b/gcc/testsuite/gcc.target/arc/loop-1.c
new file mode 100755 (executable)
index 0000000..274bb46
--- /dev/null
@@ -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];
+  }
+}