From: Claudiu Zissulescu Date: Thu, 2 Nov 2017 10:20:18 +0000 (+0100) Subject: [ARC][ZOL] Account for empty body loops X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5b5905bb077f26ba6f4a3167817da888b736d623;p=gcc.git [ARC][ZOL] Account for empty body loops gcc/ 2017-11-02 Claudiu Zissulescu * config/arc/arc.c (hwloop_optimize): Account for empty body loops. testsuite/ 2017-11-02 Claudiu Zissulescu * gcc.target/arc/loop-1.c: Add test. From-SVN: r254339 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fc871f8be9f..d80fa536551 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-11-02 Claudiu Zissulescu + + * config/arc/arc.c (hwloop_optimize): Account for empty + body loops. + 2017-11-02 Richard Biener PR middle-end/82765 diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index a0b667586b3..7336fadaea1 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -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) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c95151048d0..a8bb8caa0e5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-11-02 Claudiu Zissulescu + + * gcc.target/arc/loop-1.c: Add test. + 2017-11-02 Tom de Vries 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 index 00000000000..274bb4623c9 --- /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]; + } +}