Generate correctly typed compare in canonicalize_loop_ivs
authorTom de Vries <tdevries@suse.de>
Wed, 20 Jun 2018 14:44:45 +0000 (14:44 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Wed, 20 Jun 2018 14:44:45 +0000 (14:44 +0000)
2018-06-20  Tom de Vries  <tdevries@suse.de>

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/autopar/pr86097.c [new file with mode: 0644]
gcc/tree-ssa-loop-manip.c

index 86db35fde19825fa209b9734ca9c8a8f2a4b087f..d43118c22a3965e50d6a4e69870118d9c07788a6 100644 (file)
@@ -1,3 +1,9 @@
+2018-06-20  Tom de Vries  <tdevries@suse.de>
+
+       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  <jakub@redhat.com>
 
        * cfgrtl.c (rtl_verify_edges): Formatting fix.  If bb->preds has any
index 25a7caaebe440ac4012b0c5d679c47329047ef55..ad3b600603f57fb9600e26a0f9b1b8e8e26d4c82 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-20  Tom de Vries  <tdevries@suse.de>
+
+       PR tree-optimization/86097
+       * gcc.dg/autopar/pr86097.c: New test.
+
 2018-06-20  Nathan Sidwell  <nathan@acm.org>
 
        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 (file)
index 0000000..b48e87b
--- /dev/null
@@ -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;
+}
index bf425afd43601cf941c48dc01fdbf639c5e278f5..5acee6c98f32bcf1b46d115f2a6030cbf84b25a1 100644 (file)
@@ -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);