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/53844] [4.6/4.7 Regression] GCC generates suboptimal code for unused members of classes in some cases on multiple targets.


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53844

--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-07-04 09:55:27 UTC ---
For trunk dse_possible_dead_store_p fails to look through the loop, when
being at the VDEF .MEM_165:

<bb 3>:
  # i_93 = PHI <i_78(3), 0(2)>
  # .MEM_100 = PHI <.MEM_165(3), .MEM_68(2)>
  # VUSE <.MEM_100>
  D.3879_71 = MEM[(struct VBase *)out_2(D)].my_data;
  D.3880_73 = (long unsigned int) i_93;
  D.3881_74 = D.3880_73 * 8;
  D.3878_75 = D.3879_71 + D.3881_74;
  # VUSE <.MEM_100>
  D.3975_138 = MEM[(const struct VBase *)in_1(D)].my_data;
  D.3974_141 = D.3975_138 + D.3881_74;
  # VUSE <.MEM_100>
  D.3981_142 = *D.3974_141;
  # .MEM_165 = VDEF <.MEM_100>
  *D.3878_75 = D.3981_142;
  i_78 = i_93 + 1;
  if (i_78 != 100)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 4>:
  # .MEM_28 = VDEF <.MEM_165>
  D.2811 ={v} {CLOBBER};

we then see two uses that have a VDEF - the PHI (which we processed before),
and the store after the loop.

The following fixes that

Index: gcc/tree-ssa-dse.c
===================================================================
--- gcc/tree-ssa-dse.c  (revision 189248)
+++ gcc/tree-ssa-dse.c  (working copy)
@@ -94,7 +94,7 @@ dse_possible_dead_store_p (gimple stmt,
   temp = stmt;
   do
     {
-      gimple use_stmt;
+      gimple use_stmt, defvar_def;
       imm_use_iterator ui;
       bool fail = false;
       tree defvar;
@@ -108,6 +108,7 @@ dse_possible_dead_store_p (gimple stmt,
        defvar = PHI_RESULT (temp);
       else
        defvar = gimple_vdef (temp);
+      defvar_def = temp;
       temp = NULL;
       FOR_EACH_IMM_USE_STMT (use_stmt, ui, defvar)
        {
@@ -139,7 +140,13 @@ dse_possible_dead_store_p (gimple stmt,
                  fail = true;
                  BREAK_FROM_IMM_USE_STMT (ui);
                }
-             temp = use_stmt;
+             /* Do not consider the PHI as use if it dominates the 
+                stmt defining the virtual operand we are processing.  */
+             if (gimple_bb (defvar_def) != gimple_bb (use_stmt)
+                 && !dominated_by_p (CDI_DOMINATORS,
+                                     gimple_bb (defvar_def),
+                                     gimple_bb (use_stmt)))
+               temp = use_stmt;
            }
          /* If the statement is a use the store is not dead.  */
          else if (ref_maybe_used_by_stmt_p (use_stmt,

but the existing loop code is weird ...

I'm anyway testing the above.


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