re PR tree-optimization/92262 (ICE: verify_gimple failed (error: incorrect sharing...
authorJakub Jelinek <jakub@gcc.gnu.org>
Wed, 30 Oct 2019 09:52:01 +0000 (10:52 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 30 Oct 2019 09:52:01 +0000 (10:52 +0100)
PR tree-optimization/92262
* tree-ssa-loop-ivopts.c (get_debug_computation_at): Don't unshare
ubase or cbase here.
(remove_unused_ivs): Unshare comp before using it.

* g++.dg/opt/pr92262.C: New test.

From-SVN: r277605

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr92262.C [new file with mode: 0644]
gcc/tree-ssa-loop-ivopts.c

index db26d1b88c99a18e847a861834b320fc0f06ca23..821d97a233d28a3c306aef7e830777c934ecc4e3 100644 (file)
@@ -1,3 +1,10 @@
+2019-10-30  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/92262
+       * tree-ssa-loop-ivopts.c (get_debug_computation_at): Don't unshare
+       ubase or cbase here.
+       (remove_unused_ivs): Unshare comp before using it.
+
 2019-10-30  Jan Hubicka  <hubicka@ucw.cz>
 
        * ipa-prop.c (update_jump_functions_after_inlining):
        * config/i386/i386-builtins.c (processor_model) :
        Add M_INTEL_COREI7_TIGERLAKE and M_INTEL_COREI7_COOPERLAKE.
        (arch_names_table): Add tigerlake and cooperlake.
-       (get_builtin_code_for_version) : Handle PROCESSOR_TIGERLAKE
+       (get_builtin_code_for_version): Handle PROCESSOR_TIGERLAKE
        and PROCESSOR_COOPERLAKE.
        * config/i386/i386-c.c
        (ix86_target_macros_internal): Handle tigerlake and cooperlake.
        * config/i386/i386-options.c
-       (m_TIGERLAKE)  : Define.
-       (m_COOPERLAKE) : Ditto.
+       (m_TIGERLAKE): Define.
+       (m_COOPERLAKE): Ditto.
        (m_CORE_AVX512): Ditto.
        (processor_cost_table): Add cascadelake.
        (ix86_option_override_internal): Hadle PTA_MOVDIRI, PTA_MOVDIR64B.
        * config/i386/i386.h
-       (ix86_size_cost) : Define TARGET_TIGERLAKE and TARGET_COOPERLAKE.
-       (processor_type) : Add PROCESSOR_TIGERLAKE and PROCESSOR_COOPERLAKE.
+       (ix86_size_cost): Define TARGET_TIGERLAKE and TARGET_COOPERLAKE.
+       (processor_type): Add PROCESSOR_TIGERLAKE and PROCESSOR_COOPERLAKE.
        (PTA_MOVDIRI): Ditto.
        (PTA_MOVDIR64B): Ditto.
-       (PTA_COOPERLAKE) : Ditto.
-       (PTA_TIGERLAKE)  : Ditto.
-       (processor_type) : Add PROCESSOR_TIGERLAKE and PROCESSOR_COOPERLAKE.
+       (PTA_COOPERLAKE): Ditto.
+       (PTA_TIGERLAKE): Ditto.
+       (processor_type): Add PROCESSOR_TIGERLAKE and PROCESSOR_COOPERLAKE.
        * doc/extend.texi: Add tigerlake and cooperlake.
        * doc/invoke.texi: Add tigerlake and cooperlake.
 
 2019-04-08  wu yuan  <wuyuan5@huawei.com>
 
        * config/aarch64/aarch64-cores.def (tsv1100): Change scheduling model.
-       * config/aarch64/aarch64.md : Add "tsv110.md"
+       * config/aarch64/aarch64.md: Add "tsv110.md".
        * config/aarch64/tsv110.md: New file.
 
 2019-04-08  Richard Biener  <rguenther@suse.de>
index 23caef029631340729770f3946c82fa7b685cd00..2d1d47ab26b17f7492b08cf8e4188e38e5317138 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-30  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/92262
+       * g++.dg/opt/pr92262.C: New test.
+
 2019-10-30  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/65930
 2019-10-27  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/86248
-       * gfortran.dg/char_result_19.f90 : New test.
-       * gfortran.dg/char_result_mod_19.f90 : Module for the new test.
+       * gfortran.dg/char_result_19.f90: New test.
+       * gfortran.dg/char_result_mod_19.f90: Module for the new test.
 
 2019-10-26  Hongtao Liu  <hongtao.liu@intel.com>
 
 2019-10-05  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/91926
-       * gfortran.dg/ISO_Fortran_binding_13.f90 : New test.
-       * gfortran.dg/ISO_Fortran_binding_13.c : Additional source.
-       * gfortran.dg/ISO_Fortran_binding_14.f90 : New test.
+       * gfortran.dg/ISO_Fortran_binding_13.f90: New test.
+       * gfortran.dg/ISO_Fortran_binding_13.c: Additional source.
+       * gfortran.dg/ISO_Fortran_binding_14.f90: New test.
 
 2019-10-05  Jakub Jelinek  <jakub@redhat.com>
 
 2019-09-29  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/91726
-       * gfortran.dg/coarray_poly_9.f90 : New test.
+       * gfortran.dg/coarray_poly_9.f90: New test.
 
 2019-09-29  Kewen Lin  <linkw@gcc.gnu.org>
 
 2019-09-23  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/91729
-       * gfortran.dg/select_rank_2.f90 : Add two more errors in foo2.
-       * gfortran.dg/select_rank_3.f90 : New test.
+       * gfortran.dg/select_rank_2.f90: Add two more errors in foo2.
+       * gfortran.dg/select_rank_3.f90: New test.
 
 2019-09-23  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
 2019-09-17  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/91588
-       * gfortran.dg/associate_49.f90 : New test.
+       * gfortran.dg/associate_49.f90: New test.
 
 2019-09-17  Yannick Moy  <moy@adacore.com>
 
 2019-09-13  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/91717
-       * gfortran.dg/dependency_55.f90 : New test.
+       * gfortran.dg/dependency_55.f90: New test.
 
 2019-09-12  Uroš Bizjak  <ubizjak@gmail.com>
 
 2019-09-02  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/91589
-       * gfortran.dg/pr91589.f90 : New test.
+       * gfortran.dg/pr91589.f90: New test.
 
 2019-09-02  Steven G. Kargl  <kargl@gc.gnu.org>
 
 
 2019-09-01  Paul Thomas  <pault@gcc.gnu.org>
 
-       * gfortran.dg/select_rank_1.f90 : New test.
-       * gfortran.dg/select_rank_2.f90 : New test.
+       * gfortran.dg/select_rank_1.f90: New test.
+       * gfortran.dg/select_rank_2.f90: New test.
 
 2019-09-01  Jakub Jelinek  <jakub@redhat.com>
 
 2019-07-07  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/91077
-       * gfortran.dg/pointer_array_11.f90 : New test.
+       * gfortran.dg/pointer_array_11.f90: New test.
 
 2019-07-06  Jakub Jelinek  <jakub@redhat.com>
 
 019-06-09  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/89365
-       * gfortran.dg/assumed_rank_bounds_3.f90 : New test.
+       * gfortran.dg/assumed_rank_bounds_3.f90: New test.
 
 2019-06-08  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/90786
-       * gfortran.dg/proc_ptr_51.f90 : New test.
+       * gfortran.dg/proc_ptr_51.f90: New test.
 
 2019-06-08  Marek Polacek  <polacek@redhat.com>
 
        * gcc.target/i386/pr82699-6.c: Likewise.
        * gcc.target/i386/returninst1.c: Likewise.
        * gcc.target/i386/returninst2.c: Likewise.
-       * gcc.target/i386/returninst3.c : Likewise.
+       * gcc.target/i386/returninst3.c: Likewise.
 
 2019-05-23  Bill Schmidt  <wschmidt@linux.ibm.com>
 
 2019-05-19  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/90498
-       * gfortran.dg/associate_48.f90 : New test.
+       * gfortran.dg/associate_48.f90: New test.
 
 2019-05-19  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
 2019-02-23  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/88117
-       * gfortran.dg/deferred_character_32.f90 : New test
+       * gfortran.dg/deferred_character_32.f90: New test.
 
 2019-02-23  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/89385
-       * gfortran.dg/ISO_Fortran_binding_1.f90 : Correct test for
+       * gfortran.dg/ISO_Fortran_binding_1.f90: Correct test for
        previously incorrect lbound for allocatable expressions. Also
        correct stop values to avoid repetition.
-       * gfortran.dg/ISO_Fortran_binding_5.f90 : New test
-       * gfortran.dg/ISO_Fortran_binding_5.c : Support previous test.
+       * gfortran.dg/ISO_Fortran_binding_5.f90: New test
+       * gfortran.dg/ISO_Fortran_binding_5.c: Support previous test.
 
        PR fortran/89366
-       * gfortran.dg/ISO_Fortran_binding_6.f90 : New test
-       * gfortran.dg/ISO_Fortran_binding_6.c : Support previous test.
-       * gfortran.dg/pr32599.f03 : Set standard to F2008.
+       * gfortran.dg/ISO_Fortran_binding_6.f90: New test.
+       * gfortran.dg/ISO_Fortran_binding_6.c: Support previous test.
+       * gfortran.dg/pr32599.f03: Set standard to F2008.
 
 2019-02-22  David Malcolm  <dmalcolm@redhat.com>
 
 2019-02-09  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/89200
-       * gfortran.dg/array_reference_2.f90 : New test.
+       * gfortran.dg/array_reference_2.f90: New test.
 
 2019-02-09  Jakub Jelinek  <jakub@redhat.com>
 
 2019-02-02  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/88393
-       * gfortran.dg/alloc_comp_assign_16.f03 : New test.
+       * gfortran.dg/alloc_comp_assign_16.f03: New test.
 
 2019-02-02  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/88980
-       * gfortran.dg/realloc_on_assign_32.f90 : New test.
+       * gfortran.dg/realloc_on_assign_32.f90: New test.
 
 2019-02-02  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/88685
-       * gfortran.dg/pointer_array_component_3.f90 : New test.
+       * gfortran.dg/pointer_array_component_3.f90: New test.
 
 2019-02-02  Jakub Jelinek  <jakub@redhat.com>
 
diff --git a/gcc/testsuite/g++.dg/opt/pr92262.C b/gcc/testsuite/g++.dg/opt/pr92262.C
new file mode 100644 (file)
index 0000000..3a6478b
--- /dev/null
@@ -0,0 +1,85 @@
+// PR tree-optimization/92262
+// { dg-do compile { target c++11 } }
+// { dg-options "-O2 -ftree-loop-distribution -g" }
+
+struct A;
+struct B { template <typename T> using b = T *; };
+template <typename, typename T> using c = B::b<T>;
+void *operator new (__SIZE_TYPE__, void *p) { return p; }
+struct C {
+  template <typename T, typename... U> void
+  foo (T *x, U... y) { new (x) T(y...); }
+};
+template <typename> class D : public C {};
+template <typename> struct E;
+template <typename T> struct E<D<T>> {
+  using e = D<T>;
+  template <typename U> using f = D<U>;
+  template <typename U, typename... V>
+  static void
+  bar (e x, U y, V... z) { x.foo (y, z...); }
+};
+template <typename T> struct F : E<T> {
+  template <typename U> struct G { typedef typename E<T>::template f<U> O; };
+};
+template <typename T, typename U, typename V> void
+baz (T x, U y, V z)
+{
+  F<V>::bar (z, y, *x);
+}
+struct H {
+  typedef c<int, A> I;
+  typedef c<int, I> J;
+  I i;
+  J j;
+  void qux (J x) { j = x; }
+};
+template <typename>
+struct K {
+  K(D<A> x) : k (x) {}
+  typedef H::J L;
+  struct M { L m; H n, o; };
+  struct N : F<D<int>>::G<A>::O, M { N (F<D>::G<A>::O); };
+  void quux ();
+  N k;
+};
+template <typename T>
+void
+K<T>::quux ()
+{
+  L K (k.m - 1);
+  k.n.qux (K);
+}
+template <typename, typename = int>
+struct P : K<int> {
+  template <typename T>
+  P (T x, T, D<A> y = D<A> ()) : K (y) { corge (x); }
+  template <typename T> void corge (T);
+  typedef L L;
+};
+template <typename T, typename U>
+template <typename V>
+void P<T, U>::corge (V y)
+{
+  quux ();
+  for (L x = k.n.j; x < k.o.j; ++x)
+  {
+    ++y;
+    D<int> pv;
+    baz (y, *x, pv);
+  }
+  D<int> z;
+  baz (y, k.o.i, z);
+}
+struct A {
+  A (int x) : a (x) {}
+  int a;
+};
+int a[2]{};
+
+int
+main ()
+{
+  P<int> (a, a);
+  return 0;
+}
index 74a3ac35c8747b30e4bf9c8e9fed9c322952d89e..5938cfec08b2de510ef9173b2cf266e7664fff3f 100644 (file)
@@ -4152,8 +4152,6 @@ get_debug_computation_at (class loop *loop, gimple *at,
       var = fold_convert (ctype, var);
     }
 
-  ubase = unshare_expr (ubase);
-  cbase = unshare_expr (cbase);
   if (stmt_after_increment (loop, cand, at))
     var = fold_build2 (MINUS_EXPR, TREE_TYPE (var), var,
                       unshare_expr (cstep));
@@ -7648,6 +7646,7 @@ remove_unused_ivs (struct ivopts_data *data, bitmap toremove)
              if (!best_cand)
                continue;
 
+             comp = unshare_expr (comp);
              if (count > 1)
                {
                  tree vexpr = make_node (DEBUG_EXPR_DECL);