From 2359e571cd71026167931216e730129d53244dd1 Mon Sep 17 00:00:00 2001 From: Bin Cheng Date: Thu, 21 Apr 2016 11:28:58 +0000 Subject: [PATCH] re PR tree-optimization/70715 (SCEV failed to prove no-overflow-ness information unsigned loop IV) PR tree-optimization/70715 * tree-ssa-loop-niter.c (loop_exits_before_overflow): Check equality after expanding BASE using expand_simple_operations. gcc/testsuite/ChangeLog PR tree-optimization/70715 * gcc.dg/tree-ssa/scev-13.c: New test. From-SVN: r235333 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/tree-ssa/scev-13.c | 15 +++++++++++++++ gcc/tree-ssa-loop-niter.c | 6 +++++- 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/scev-13.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 86bee074b69..a3412c90029 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-04-21 Bin Cheng + + PR tree-optimization/70715 + * tree-ssa-loop-niter.c (loop_exits_before_overflow): Check equality + after expanding BASE using expand_simple_operations. + 2016-04-21 Marc Glisse * match.pd (min(-x, -y), max(-x, -y), min(~x, ~y), max(~x, ~y)): diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 08f70405c52..7a17aa2ebb6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-04-21 Bin Cheng + + PR tree-optimization/70715 + * gcc.dg/tree-ssa/scev-13.c: New test. + 2016-04-21 Marc Glisse * gcc.dg/tree-ssa/minmax-2.c: New testcase. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/scev-13.c b/gcc/testsuite/gcc.dg/tree-ssa/scev-13.c new file mode 100644 index 00000000000..b9223c80e7b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/scev-13.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-ldist" } */ + +int +foo (char *p, unsigned n) +{ + while(n--) + { + p[n]='A'; + } + return 0; +} + +/* Loop can be transformed into builtin memset since &p[n] is SCEV. */ +/* { dg-final { scan-tree-dump "builtin_memset" "ldist" } } */ diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 81689fc1aa4..c61083e7fd3 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -4141,7 +4141,11 @@ loop_exits_before_overflow (tree base, tree step, continue; /* Done proving if this is a no-overflow control IV. */ - if (operand_equal_p (base, civ->base, 0)) + if (operand_equal_p (base, civ->base, 0) + /* Control IV is recorded after expanding simple operations, + Here we compare it against expanded base too. */ + || operand_equal_p (expand_simple_operations (base), + civ->base, 0)) return true; /* If this is a before stepping control IV, in other words, we have