public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5447] tree-optimization/103351 - avoid compare-debug issue wrt CD-DCE change
@ 2021-11-22 11:18 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-11-22 11:18 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f456eaf2e0fb3ceb51c641fd348429bf59d215a9

commit r12-5447-gf456eaf2e0fb3ceb51c641fd348429bf59d215a9
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Nov 22 11:23:55 2021 +0100

    tree-optimization/103351 - avoid compare-debug issue wrt CD-DCE change
    
    This avoids differences in the split edge of a cluster due to different
    order of same key PHI args when sorting by sorting after the edge
    destination index as second key.
    
    2021-11-22  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/103351
            * tree-ssa-dce.c (sort_phi_args): Sort after e->dest_idx as
            second key.
    
            * g++.dg/torture/pr103351.C: New testcase.

Diff:
---
 gcc/testsuite/g++.dg/torture/pr103351.C | 88 +++++++++++++++++++++++++++++++++
 gcc/tree-ssa-dce.c                      |  4 ++
 2 files changed, 92 insertions(+)

diff --git a/gcc/testsuite/g++.dg/torture/pr103351.C b/gcc/testsuite/g++.dg/torture/pr103351.C
new file mode 100644
index 00000000000..d0bf7216ffc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr103351.C
@@ -0,0 +1,88 @@
+// { dg-do compile }
+// { dg-additional-options "-fcompare-debug" }
+
+template <int> struct __conditional;
+template <bool _Cond, typename, typename>
+using __conditional_t = typename __conditional<_Cond>::type;
+template <typename> struct __is_void_helper {};
+template <typename _Tp> _Tp *__addressof(_Tp &__r) {
+  return __builtin_addressof(__r);
+}
+template <typename _Tp> _Tp *addressof(_Tp &__r) { return __addressof(__r); }
+template <typename _Tp>
+using __make_not_void = __conditional_t<_Tp ::value, int, _Tp>;
+template <typename> struct pointer_traits;
+template <typename _Tp> struct pointer_traits<_Tp *> {
+  typedef _Tp *pointer;
+  typedef _Tp element_type;
+  static pointer pointer_to(element_type &__r) { return addressof(__r); }
+};
+namespace {
+template <typename> struct new_allocator;
+}
+template <typename> struct allocator_traits;
+template <typename> struct allocator;
+template <typename _Tp> struct allocator_traits<allocator<_Tp>> {
+  using pointer = _Tp *;
+  using const_pointer = _Tp *;
+};
+namespace __gnu_cxx {
+template <typename = char>
+struct __alloc_traits : allocator_traits<allocator<char>> {};
+} // namespace __gnu_cxx
+template <class> struct char_traits;
+template <typename _CharT, typename = _CharT>
+class Trans_NS___cxx11_basic_string;
+template <> struct char_traits<char> {
+  typedef char char_type;
+  static void assign(char_type, char_type);
+};
+template <typename, typename> struct Trans_NS___cxx11_basic_string {
+  typedef __gnu_cxx::__alloc_traits<> _Alloc_traits;
+  typedef char_traits<char> traits_type;
+  typedef _Alloc_traits::pointer pointer;
+  typedef _Alloc_traits::const_pointer const_pointer;
+  struct {
+    pointer _M_p;
+  } _M_dataplus;
+  char _M_local_buf[];
+  void _M_data(pointer __p) { _M_dataplus._M_p = __p; }
+  bool _M_is_local() {
+    const_pointer __trans_tmp_5 =
+        pointer_traits<const_pointer>::pointer_to(*_M_local_buf);
+    return _M_dataplus._M_p == __trans_tmp_5;
+  }
+  void operator=(Trans_NS___cxx11_basic_string __str) {
+    bool __trans_tmp_2;
+    if (__str._M_is_local()) {
+      Trans_NS___cxx11_basic_string *__trans_tmp_1;
+      if (__builtin_expect(__trans_tmp_1 != this, true))
+        size();
+    } else if (__trans_tmp_2)
+      __str._M_data(__str._M_local_buf);
+    __str.clear();
+  }
+  void size();
+  void clear() { traits_type::assign(_M_dataplus._M_p[0], char()); }
+};
+template <class, typename, int> struct Pool {
+  template <class T> struct PoolIterator {
+    bool operator!=(PoolIterator);
+    T *operator*();
+    void operator++();
+  };
+  template <class T> struct IterateWrapper {
+    PoolIterator<T> begin();
+    PoolIterator<T> end();
+  };
+};
+struct BaseConsist {
+  Trans_NS___cxx11_basic_string<char> name;
+};
+struct Vehicle : BaseConsist {};
+Pool<int, int, true>::IterateWrapper<Vehicle> __trans_tmp_4;
+Trans_NS___cxx11_basic_string<char> __trans_tmp_6;
+void FixOldVehicles() {
+  for (Vehicle *v : __trans_tmp_4)
+    v->name = __trans_tmp_6;
+}
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index dbf02c434de..e3e6f0955b7 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -1626,6 +1626,10 @@ sort_phi_args (const void *a_, const void *b_)
     return -1;
   else if (ha > hb)
     return 1;
+  else if (a->first->dest_idx < b->first->dest_idx)
+    return -1;
+  else if (a->first->dest_idx > b->first->dest_idx)
+    return 1;
   else
     return 0;
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-22 11:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-22 11:18 [gcc r12-5447] tree-optimization/103351 - avoid compare-debug issue wrt CD-DCE change Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).