While working on PR57359 I noticed that a change during GCC 9
development broke a pointer equality check in ref_always_accessed.
The following corrects this - the way LIM works it is enough
to check for store vs. load.

The issue leads to more conditional SMs than necessary.

Bootstrap / regtest running on x86_64-unknown-linux-gnu.

Richard.


This fixes a regression when canonicalizing refs for LIM PR84362.
This possibly unshares and rewrites the refs in the internal data
and thus pointer equality no longer works in ref_always_accessed
computation.

2020-04-28  Richard Biener  <rguent...@suse.de>

        * tree-ssa-loop-im.c (ref_always_accessed::operator ()):
        Just check whether the stmt stores.
---
 gcc/tree-ssa-loop-im.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index 2bb47e9d6d2..471b620f2c4 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -2407,20 +2407,21 @@ ref_always_accessed::operator () (mem_ref_loc *loc)
 {
   class loop *must_exec;
 
-  if (!get_lim_data (loc->stmt))
+  struct lim_aux_data *lim_data = get_lim_data (loc->stmt);
+  if (!lim_data)
     return false;
 
   /* If we require an always executed store make sure the statement
-     stores to the reference.  */
+     is a store.  */
   if (stored_p)
     {
       tree lhs = gimple_get_lhs (loc->stmt);
       if (!lhs
-         || lhs != *loc->ref)
+         || !(DECL_P (lhs) || REFERENCE_CLASS_P (lhs)))
        return false;
     }
 
-  must_exec = get_lim_data (loc->stmt)->always_executed_in;
+  must_exec = lim_data->always_executed_in;
   if (!must_exec)
     return false;
 
-- 
2.13.7

Reply via email to