aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2007-07-04 12:38:23 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2007-07-04 12:38:23 +0000
commitf6024dfe095eefaad68cd613647c10bb02f13a0f (patch)
tree81d89782e16343bad4f0f27e9693455a164e858b
parent5357b4b7b972e5d18df639d20313c61c1c832cd0 (diff)
2007-07-04 Richard Guenther <rguenther@suse.de>ubuntu/gcc-4_2-branchpoint
PR tree-optimization/32500 * tree-ssa-loop-niter.c (infer_loop_bounds_from_undefined): Only use basic blocks that are always executed to infer loop bounds. * gcc.c-torture/execute/pr32500.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_2-branch@126315 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr32500.c26
-rw-r--r--gcc/tree-ssa-loop-niter.c6
4 files changed, 43 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 64f70c81959..561193c17a6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2007-07-04 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/32500
+ * tree-ssa-loop-niter.c (infer_loop_bounds_from_undefined):
+ Only use basic blocks that are always executed to infer loop bounds.
+
2007-07-04 Uros Bizjak <ubizjak@gmail.com>
PR tree-optimization/31966
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 561ab7c0e15..25154d64726 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2007-07-04 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/32500
+ * gcc.c-torture/execute/pr32500.c: New testcase.
+
2007-07-04 Uros Bizjak <ubizjak@gmail.com>
PR tree-optimization/31966
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr32500.c b/gcc/testsuite/gcc.c-torture/execute/pr32500.c
new file mode 100644
index 00000000000..dae06ea3a25
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr32500.c
@@ -0,0 +1,26 @@
+extern void abort(void);
+extern void exit(int);
+void foo(int) __attribute__((noinline));
+void bar(void) __attribute__((noinline));
+
+/* Make sure foo is not inlined or considered pure/const. */
+int x;
+void foo(int i) { x = i; }
+void bar(void) { exit(0); }
+
+int
+main(int argc, char *argv[])
+{
+ int i;
+ int numbers[4] = { 0xdead, 0xbeef, 0x1337, 0x4242 };
+
+ for (i = 1; i <= 12; i++) {
+ if (i <= 4)
+ foo(numbers[i]);
+ else if (i >= 7 && i <= 9)
+ bar();
+ }
+
+ abort();
+}
+
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index b087bca23aa..429622bcf60 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -1747,6 +1747,12 @@ infer_loop_bounds_from_undefined (struct loop *loop)
{
bb = bbs[i];
+ /* If BB is not executed in each iteration of the loop, we cannot
+ use the operations in it to infer reliable upper bound on the
+ # of iterations of the loop. */
+ if (!dominated_by_p (CDI_DOMINATORS, loop->latch, bb))
+ continue;
+
for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
{
tree stmt = bsi_stmt (bsi);