This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix PR78725
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Michael Matz <matz at suse dot de>,gcc-patches at gcc dot gnu dot org
- Date: Fri, 09 Dec 2016 19:53:08 +0100
- Subject: Re: Fix PR78725
- Authentication-results: sourceware.org; auth=none
- References: <alpine.LSU.2.20.1612091626370.31313@wotan.suse.de>
On December 9, 2016 4:29:04 PM GMT+01:00, Michael Matz <matz@suse.de> wrote:
>Hi,
>
>if the induction variable on which we want to partition the loop
>iterations for loop splitting might overflow we would either need
>runtime
>tests checking if an overflow in fact does happen, or we can simply not
>
>split loops on such ones. I chose the latter.
>
>Fixes the testcase, and regstrapped without regressions on x86-64-linux
>
>(all languages+Ada). Okay for trunk?
OK
Thanks,
Richard.
>
>Ciao,
>Michael.
> PR tree-optimization/78725
> * tree-ssa-loop-split.c (split_at_bb_p): Check for overflow.
>
>testsuite/
> PR tree-optimization/78725
> * gcc.dg/pr78725.c: New test.
>
>diff --git a/gcc/testsuite/gcc.dg/pr78725.c
>b/gcc/testsuite/gcc.dg/pr78725.c
>new file mode 100644
>index 0000000..9d76047
>--- /dev/null
>+++ b/gcc/testsuite/gcc.dg/pr78725.c
>@@ -0,0 +1,19 @@
>+/* { dg-do run } */
>+/* { dg-options "-O3" } */
>+
>+int fn1 (int b, int c)
>+{
>+ return c < 0 || c > 31 ? 0 : b >> c;
>+}
>+
>+unsigned char d = 255;
>+int e, f;
>+
>+int main ()
>+{
>+ for (; f < 2; f++)
>+ e = fn1 (1, d++);
>+ if (e != 1)
>+ __builtin_abort ();
>+ return 0;
>+}
>diff --git a/gcc/tree-ssa-loop-split.c b/gcc/tree-ssa-loop-split.c
>index dac68e6..a78d23f 100644
>--- a/gcc/tree-ssa-loop-split.c
>+++ b/gcc/tree-ssa-loop-split.c
>@@ -122,6 +122,8 @@ split_at_bb_p (struct loop *loop, basic_block bb,
>tree *border, affine_iv *iv)
> return NULL_TREE;
> if (!integer_zerop (iv2.step))
> return NULL_TREE;
>+ if (!iv->no_overflow)
>+ return NULL_TREE;
>
> if (dump_file && (dump_flags & TDF_DETAILS))
> {