This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PR tree-optimization/55569 (profile updating ICE)
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 9 Jan 2013 16:06:32 +0100
- Subject: PR tree-optimization/55569 (profile updating ICE)
Hi,
this patch fixes problem with negative probabilities that result in overflow on
ITERATION_BOUND parameter that is taken from niter code returning wider values
than int. I went for gcov_type instead of HOST_WIDE_INT because it makes sense
to derive the bounds from profile, too.
Will commit it as obvious once bootstrap/regtest on x86_64 complette.
Honza
PR tree-optimization/55569
* cfgloopmanip.c (scale_loop_profile): Make ITERATION_BOUND gcov_type.
* cfgloop.h (scale_loop_profile): Likewise.
* gcc.c-torture/compile/pr55569.c: New testcase.
Index: cfgloopmanip.c
===================================================================
--- cfgloopmanip.c (revision 195047)
+++ cfgloopmanip.c (working copy)
@@ -481,7 +481,7 @@ scale_loop_frequencies (struct loop *loo
to iterate too many times. */
void
-scale_loop_profile (struct loop *loop, int scale, int iteration_bound)
+scale_loop_profile (struct loop *loop, int scale, gcov_type iteration_bound)
{
gcov_type iterations = expected_loop_iterations_unbounded (loop);
edge e;
Index: cfgloop.h
===================================================================
--- cfgloop.h (revision 195047)
+++ cfgloop.h (working copy)
@@ -711,7 +711,7 @@ extern void unroll_and_peel_loops (int);
extern void doloop_optimize_loops (void);
extern void move_loop_invariants (void);
extern bool finite_loop_p (struct loop *);
-extern void scale_loop_profile (struct loop *loop, int scale, int iteration_bound);
+extern void scale_loop_profile (struct loop *loop, int scale, gcov_type iteration_bound);
extern vec<basic_block> get_loop_hot_path (const struct loop *loop);
/* Returns the outermost loop of the loop nest that contains LOOP.*/
Index: testsuite/gcc.c-torture/compile/pr55569.c
===================================================================
--- testsuite/gcc.c-torture/compile/pr55569.c (revision 0)
+++ testsuite/gcc.c-torture/compile/pr55569.c (revision 0)
@@ -0,0 +1,11 @@
+/* { dg-options "-O1 -ftree-vectorize" } */
+int *bar (void);
+
+void
+foo (void)
+{
+ long x;
+ int *y = bar ();
+ for (x = -1 / sizeof (int); x; --x, ++y)
+ *y = 0;
+}