re PR tree-optimization/86489 (ICE in gimple_phi_arg starting with r261682 when build...
authorKugan Vivekanandarajah <kuganv@linaro.org>
Fri, 13 Jul 2018 05:25:47 +0000 (05:25 +0000)
committerKugan Vivekanandarajah <kugan@gcc.gnu.org>
Fri, 13 Jul 2018 05:25:47 +0000 (05:25 +0000)
gcc/ChangeLog:

2018-07-13  Kugan Vivekanandarajah  <kuganv@linaro.org>
    Richard Biener  <rguenther@suse.de>

PR middle-end/86489
* tree-ssa-loop-niter.c (number_of_iterations_popcount): Check
that the loop latch destination where phi is defined.

gcc/testsuite/ChangeLog:

2018-07-13  Kugan Vivekanandarajah  <kuganv@linaro.org>

PR middle-end/86489
* gcc.dg/pr86489.c: New test.

Co-Authored-By: Richard Biener <rguenther@suse.de>
From-SVN: r262622

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr86489.c [new file with mode: 0644]
gcc/tree-ssa-loop-niter.c

index 9c955669e174bc82becca952dd894c8f834f18f4..0cfa2309c61d1835093ce9fe8bff51f4a218208e 100644 (file)
@@ -1,3 +1,10 @@
+2018-07-13  Kugan Vivekanandarajah  <kuganv@linaro.org>
+           Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/86489
+       * tree-ssa-loop-niter.c (number_of_iterations_popcount): Check
+       that the loop latch destination where phi is defined.
+
 2018-07-12  Kito Cheng  <kito.cheng@gmail.com>
 
         * config/riscv/riscv.c (enum riscv_privilege_levels): Add UNKNOWN_MODE.
index a5ace640fd1b4a236b88d9600c8536c93c603ae3..9d6c7cc7d9978edfbd92a3936f5eb0ef68b60d6e 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-13  Kugan Vivekanandarajah  <kuganv@linaro.org>
+
+       PR middle-end/86489
+       * gcc.dg/pr86489.c: New test.
+
 2018-07-12  Martin Sebor  <msebor@redhat.com>
 
        PR testsuite/86510
diff --git a/gcc/testsuite/gcc.dg/pr86489.c b/gcc/testsuite/gcc.dg/pr86489.c
new file mode 100644 (file)
index 0000000..c7e5573
--- /dev/null
@@ -0,0 +1,12 @@
+
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int a = 0, b = 0;
+void fn1() {
+    int c = 0;
+    for (; a; a--)
+      c += b;
+    while ((c - 1) & c)
+      ;
+}
index f6fa2f74744074730ad3a910d92bf4f11dd7db01..fbdf838496bc558b8b5df191bcc5416ed19d0176 100644 (file)
@@ -2555,6 +2555,7 @@ number_of_iterations_popcount (loop_p loop, edge exit,
    ... = PHI <b_5(2), b_6(3)>.  */
   gimple *phi = SSA_NAME_DEF_STMT (b_11);
   if (gimple_code (phi) != GIMPLE_PHI
+      || (gimple_bb (phi) != loop_latch_edge (loop)->dest)
       || (gimple_assign_lhs (and_stmt)
          != gimple_phi_arg_def (phi, loop_latch_edge (loop)->dest_idx)))
     return false;