https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99473

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot 
gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
g3 and g1 behave differently also because of (there's a dup PR I can't find
right now) sinking happening in a way that the pass store-commoning code
doesn't trigger on the sunk store.

cselim doesn't trigger because

  if ((TREE_CODE (lhs) != MEM_REF
       && TREE_CODE (lhs) != ARRAY_REF
       && TREE_CODE (lhs) != COMPONENT_REF)
      || !is_gimple_reg_type (TREE_TYPE (lhs)))
    return false;

lhs is a VAR_DECL and 'nontrap' only tracks pointers.  There's code to actually
handle auto-vars now but the above still disallows bare decls.  Because
we have the address-taken the transform will also require
-fallow-store-data-races.

diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index ddd9d531b13..6f7efa29a1b 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -2490,9 +2490,8 @@ cond_store_replacement (basic_block middle_bb,
basic_block join_bb,
   locus = gimple_location (assign);
   lhs = gimple_assign_lhs (assign);
   rhs = gimple_assign_rhs1 (assign);
-  if ((TREE_CODE (lhs) != MEM_REF
-       && TREE_CODE (lhs) != ARRAY_REF
-       && TREE_CODE (lhs) != COMPONENT_REF)
+  if ((!REFERENCE_CLASS_P (lhs)
+       && !DECL_P (lhs))
       || !is_gimple_reg_type (TREE_TYPE (lhs)))
     return false;


fixes g3 this (with -fallow-store-data-races).  Queued for GCC 12.

g2 needs sinking/commoning of f (&x) for which there's yet another PR I think.

Reply via email to