aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2020-10-28 16:41:15 -0400
committerAndrew MacLeod <amacleod@redhat.com>2020-10-28 22:02:45 -0400
commit0162d00d12be24ee3f02ce876adafeaa91c6f7f9 (patch)
tree6ba997f13de10d9e7e4e7ffc8189b5508ae94f89 /gcc
parentc6bfc4eb3c961181912647781d7dd38057db655b (diff)
downloadgcc-0162d00d12be24ee3f02ce876adafeaa91c6f7f9.zip
gcc-0162d00d12be24ee3f02ce876adafeaa91c6f7f9.tar.gz
gcc-0162d00d12be24ee3f02ce876adafeaa91c6f7f9.tar.bz2
Call infer_non_null() directly when checking for non-null.
Simply call infer_non_null directly and avoid uneccessary checks of the statement being modified. gcc/ PR tree-optimization/97609 * gimple-range-cache.cc (non_null_ref::process_name): Call infer_nonnull_range directly instead of infer_value_range. gcc/testsuite/ * g++.dg/pr97609.C: New.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gimple-range-cache.cc12
-rw-r--r--gcc/testsuite/g++.dg/pr97609.C46
2 files changed, 50 insertions, 8 deletions
diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index 13b9933..bc9243c 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -91,19 +91,15 @@ non_null_ref::process_name (tree name)
{
gimple *s = USE_STMT (use_p);
unsigned index = gimple_bb (s)->index;
- tree value;
- enum tree_code comp_code;
// If bit is already set for this block, dont bother looking again.
if (bitmap_bit_p (b, index))
continue;
- // If we can infer a != 0 range, then set the bit for this BB
- if (infer_value_range (s, name, &comp_code, &value))
- {
- if (comp_code == NE_EXPR && integer_zerop (value))
- bitmap_set_bit (b, index);
- }
+ // If we can infer a nonnull range, then set the bit for this BB
+ if (!SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name)
+ && infer_nonnull_range (s, name))
+ bitmap_set_bit (b, index);
}
m_nn[v] = b;
diff --git a/gcc/testsuite/g++.dg/pr97609.C b/gcc/testsuite/g++.dg/pr97609.C
new file mode 100644
index 0000000..8e582c9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr97609.C
@@ -0,0 +1,46 @@
+// PR tree-optimization/97609
+// { dg-do compile { target c++11 } }
+// { dg-options "-O2 -fno-tree-fre -fnon-call-exceptions" }
+
+struct _Fwd_list_node_base {
+ _Fwd_list_node_base *_M_next;
+ void _M_transfer_after() { _Fwd_list_node_base *__keep = _M_next = __keep; }
+};
+struct _Fwd_list_const_iterator {
+ _Fwd_list_const_iterator(_Fwd_list_node_base *__n) : _M_node(__n) {}
+ _Fwd_list_const_iterator(int);
+ _Fwd_list_node_base *_M_node;
+};
+template <typename, typename> struct forward_list {
+ _Fwd_list_node_base _M_head;
+ template <typename _InputIterator>
+ forward_list(_InputIterator, _InputIterator);
+ forward_list(int);
+ _Fwd_list_const_iterator cbefore_begin() { return &_M_head; }
+ void splice_after(_Fwd_list_const_iterator) noexcept;
+ void splice_after(_Fwd_list_const_iterator __pos, forward_list &) {
+ splice_after(__pos, 0);
+ }
+ using __remove_return_type = void;
+ __remove_return_type unique() { unique(0); }
+ template <typename _BinPred> __remove_return_type unique(_BinPred);
+};
+template <typename _Tp, typename _Alloc>
+void forward_list<_Tp, _Alloc>::splice_after(_Fwd_list_const_iterator __pos)
+ noexcept {
+ __pos._M_node->_M_transfer_after();
+}
+template <typename _Tp, typename _Alloc>
+template <typename _BinPred>
+auto forward_list<_Tp, _Alloc>::unique(_BinPred) -> __remove_return_type {
+ forward_list __to_destroy(0);
+ splice_after(__to_destroy.cbefore_begin());
+}
+
+void
+foo ()
+{
+ forward_list<int, int> c1 (0, 0);
+ c1.unique ();
+}
+