This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/85757] tree optimizers fail to fully clean up fixed-size memcpy


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kugan at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
This is the failure to handle non-aliasing stores.  We get it recorded here:

          /* If this is a store, remember it or bail out if we have
             multiple ones (the will be in different CFG parts then).  */
          else if (gimple_vdef (use_stmt))
            {
              if (temp)
                {
                  fail = true;
                  BREAK_FROM_IMM_USE_STMT (ui);
                }
              temp = use_stmt;
            }

but that's necessary for the walking algorithm.  Basically PHI handling was
added for a few ad-hoc cases.

diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
index 9220fea7f2e..ab5aa5bb314 100644
--- a/gcc/tree-ssa-dse.c
+++ b/gcc/tree-ssa-dse.c
@@ -569,7 +569,8 @@ dse_classify_store (ao_ref *ref, gimple *stmt, gimple
**use_stmt,
             See gcc.c-torture/execute/20051110-*.c.  */
          else if (gimple_code (use_stmt) == GIMPLE_PHI)
            {
-             if (temp
+             if ((temp
+                  && stmt_may_clobber_ref_p_1 (temp, ref))
                  /* Make sure we are not in a loop latch block.  */
                  || gimple_bb (stmt) == gimple_bb (use_stmt)
                  || dominated_by_p (CDI_DOMINATORS,

"solves" half of it.  But the above snipped needs similar treatment for
the case of temp being the PHI.

Basically a more programatical approach of walking the individual paths
into the PHI node is required which, for clarity, should require
refactoring of the walk.  walk_nonaliased_vuses and friends may or may not
be a good copying source.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]