aboutsummaryrefslogtreecommitdiff
path: root/gcc/predict.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2013-01-09 09:00:22 +0000
committerJakub Jelinek <jakub@redhat.com>2013-01-09 09:00:22 +0000
commit232d7708785f0ab9f7dc7bb76bba3aa74a59158d (patch)
tree0062efccf829343f841ef19cff0256321501ad8c /gcc/predict.c
parentcbcb33e694874c5d133fe2504de92d1fc63e7ae1 (diff)
PR tree-optimization/48189
* predict.c (predict_loops): If max is 0, don't call compare_tree_int. If nitercst is 0, don't predict the exit edge. * gcc.dg/pr48189.c: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@195046 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/predict.c')
-rw-r--r--gcc/predict.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/predict.c b/gcc/predict.c
index 0c16b537c4b..67a5f74ec6c 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -1,6 +1,6 @@
/* Branch prediction routines for the GNU compiler.
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010,
- 2011, 2012 Free Software Foundation, Inc.
+ 2011, 2012, 2013 Free Software Foundation, Inc.
This file is part of GCC.
@@ -1434,7 +1434,8 @@ predict_loops (void)
if (TREE_CODE (niter) == INTEGER_CST)
{
if (host_integerp (niter, 1)
- && compare_tree_int (niter, max-1) == -1)
+ && max
+ && compare_tree_int (niter, max - 1) == -1)
nitercst = tree_low_cst (niter, 1) + 1;
else
nitercst = max;
@@ -1456,6 +1457,11 @@ predict_loops (void)
else
continue;
+ /* If the prediction for number of iterations is zero, do not
+ predict the exit edges. */
+ if (nitercst == 0)
+ continue;
+
probability = ((REG_BR_PROB_BASE + nitercst / 2) / nitercst);
predict_edge (ex, predictor, probability);
}