From: Tom de Vries Date: Wed, 20 Jun 2018 14:44:45 +0000 (+0000) Subject: Generate correctly typed compare in canonicalize_loop_ivs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=60f02f902170249d3a7fe763c10c1aa9375b1150;p=gcc.git Generate correctly typed compare in canonicalize_loop_ivs 2018-06-20 Tom de Vries PR tree-optimization/86097 * tree-ssa-loop-manip.c (canonicalize_loop_ivs): Also convert *nit to iv type if signedness of iv type is not the same as that of *nit. * gcc.dg/autopar/pr86097.c: New test. From-SVN: r261804 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 86db35fde19..d43118c22a3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-06-20 Tom de Vries + + PR tree-optimization/86097 + * tree-ssa-loop-manip.c (canonicalize_loop_ivs): Also convert *nit to + iv type if signedness of iv type is not the same as that of *nit. + 2018-06-20 Jakub Jelinek * cfgrtl.c (rtl_verify_edges): Formatting fix. If bb->preds has any diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 25a7caaebe4..ad3b600603f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-06-20 Tom de Vries + + PR tree-optimization/86097 + * gcc.dg/autopar/pr86097.c: New test. + 2018-06-20 Nathan Sidwell PR c++/85634 diff --git a/gcc/testsuite/gcc.dg/autopar/pr86097.c b/gcc/testsuite/gcc.dg/autopar/pr86097.c new file mode 100644 index 00000000000..b48e87b8bf9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/autopar/pr86097.c @@ -0,0 +1,31 @@ +/* { dg-options "-O2 -ftree-parallelize-loops=2 -fno-tree-dce -Wno-aggressive-loop-optimizations" } */ +int rp, vd; + +void +p5 (int cd) +{ + while (cd != 0) + { + for (rp = 0; rp < 4; ++rp) + for (vd = 0; vd < 1; ++vd) + { + g0: + ; + } + + ++rp; + } + + while (rp < 2) + { + for (cd = 0; cd < 1; ++cd) + for (rp = 1; rp != 0; ++rp) + { + } + + ++rp; + } + + if (cd != 0) + goto g0; +} diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c index bf425afd436..5acee6c98f3 100644 --- a/gcc/tree-ssa-loop-manip.c +++ b/gcc/tree-ssa-loop-manip.c @@ -1542,7 +1542,8 @@ canonicalize_loop_ivs (struct loop *loop, tree *nit, bool bump_in_latch) precision = GET_MODE_PRECISION (mode); type = build_nonstandard_integer_type (precision, unsigned_p); - if (original_precision != precision) + if (original_precision != precision + || TYPE_UNSIGNED (TREE_TYPE (*nit)) != unsigned_p) { *nit = fold_convert (type, *nit); *nit = force_gimple_operand (*nit, &stmts, true, NULL_TREE);