Fix off by one error in loop-unroll.c (PR rtl-optimization/82675).

Message ID 8d53b92a-daeb-e031-a933-0a549b2a5bc3@suse.cz
State New
Headers show
Series
  • Fix off by one error in loop-unroll.c (PR rtl-optimization/82675).
Related show

Commit Message

Martin Liška Dec. 19, 2017, 7:56 a.m.
Hello.

Following patch fixes off by one in loop unroller where wont_exit has
not enough elements that are later on asked for.

Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Ready to be installed?
Martin

gcc/ChangeLog:

2017-11-08  Martin Liska  <mliska@suse.cz>

	PR rtl-optimization/82675
	* loop-unroll.c (unroll_loop_constant_iterations): Allocate one
	more element in sbitmap.
---
 gcc/loop-unroll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Richard Biener Dec. 19, 2017, 11:51 a.m. | #1
On Tue, Dec 19, 2017 at 8:56 AM, Martin Liška <mliska@suse.cz> wrote:
> Hello.

>

> Following patch fixes off by one in loop unroller where wont_exit has

> not enough elements that are later on asked for.

>

> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

>

> Ready to be installed?


Ok.

> Martin

>

> gcc/ChangeLog:

>

> 2017-11-08  Martin Liska  <mliska@suse.cz>

>

>         PR rtl-optimization/82675

>         * loop-unroll.c (unroll_loop_constant_iterations): Allocate one

>         more element in sbitmap.

> ---

>  gcc/loop-unroll.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

>

>

Patch

diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c
index 91bf5dddeed..2fab92bcf74 100644
--- a/gcc/loop-unroll.c
+++ b/gcc/loop-unroll.c
@@ -477,7 +477,7 @@  unroll_loop_constant_iterations (struct loop *loop)
 
   exit_mod = niter % (max_unroll + 1);
 
-  auto_sbitmap wont_exit (max_unroll + 1);
+  auto_sbitmap wont_exit (max_unroll + 2);
   bitmap_ones (wont_exit);
 
   auto_vec<edge> remove_edges;