]> git.ipfire.org Git - people/ms/gcc.git/commitdiff
Do not continue propagating values which cannot be set properly.
authorAndrew MacLeod <amacleod@redhat.com>
Tue, 22 Jun 2021 21:46:05 +0000 (17:46 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Wed, 14 Jul 2021 19:14:20 +0000 (15:14 -0400)
If the on-entry cache cannot properly represent a range, do not continue
trying to propagate it.

PR tree-optimization/101148
PR tree-optimization/101014
* gimple-range-cache.cc (ranger_cache::ranger_cache): Adjust.
(ranger_cache::~ranger_cache): Adjust.
(ranger_cache::block_range): Check if propagation disallowed.
(ranger_cache::propagate_cache): Disallow propagation if new value
can't be stored properly.
* gimple-range-cache.h (ranger_cache::m_propfail): New member.

gcc/gimple-range-cache.cc
gcc/gimple-range-cache.h

index 610d4c505315715bd9ca5b5b0c1f4eab41bcd7d2..ff0084545ab99099cb1d2593add72980e445e13c 100644 (file)
@@ -742,10 +742,12 @@ ranger_cache::ranger_cache (gimple_ranger &q) : query (q)
   m_poor_value_list.safe_grow_cleared (20);
   m_poor_value_list.truncate (0);
   m_temporal = new temporal_cache;
+  m_propfail = BITMAP_ALLOC (NULL);
 }
 
 ranger_cache::~ranger_cache ()
 {
+  BITMAP_FREE (m_propfail);
   delete m_temporal;
   m_poor_value_list.release ();
   m_workback.release ();
@@ -958,7 +960,9 @@ ranger_cache::block_range (irange &r, basic_block bb, tree name, bool calc)
 void
 ranger_cache::add_to_update (basic_block bb)
 {
-  if (!m_update_list.contains (bb))
+  // If propagation has failed for BB, or its already in the list, don't
+  // add it again.
+  if (!bitmap_bit_p (m_propfail, bb->index) &&  !m_update_list.contains (bb))
     m_update_list.quick_push (bb);
 }
 
@@ -975,6 +979,7 @@ ranger_cache::propagate_cache (tree name)
   int_range_max current_range;
   int_range_max e_range;
 
+  gcc_checking_assert (bitmap_empty_p (m_propfail));
   // Process each block by seeing if its calculated range on entry is
   // the same as its cached value. If there is a difference, update
   // the cache to reflect the new value, and check to see if any
@@ -1031,6 +1036,9 @@ ranger_cache::propagate_cache (tree name)
       if (new_range != current_range)
        {
          bool ok_p = m_on_entry.set_bb_range (name, bb, new_range);
+         // If the cache couldn't set the value, mark it as failed.
+         if (!ok_p)
+           bitmap_set_bit (m_propfail, bb->index);
          if (DEBUG_RANGE_CACHE) 
            {
              if (!ok_p)
@@ -1060,6 +1068,7 @@ ranger_cache::propagate_cache (tree name)
       print_generic_expr (dump_file, name, TDF_SLIM);
       fprintf (dump_file, "\n");
     }
+  bitmap_clear (m_propfail);
 }
 
 // Check to see if an update to the value for NAME in BB has any effect
index f82816f10c11967e7f94f398d4093d48ab43d4f2..d536f09940f72f4437b2b750e84a8e4cf4110b7c 100644 (file)
@@ -115,6 +115,7 @@ private:
 
   void propagate_updated_value (tree name, basic_block bb);
 
+  bitmap m_propfail;
   vec<basic_block> m_workback;
   vec<basic_block> m_update_list;