The following fixes PR58246 by fixing a dominator check.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2013-08-29  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/58246
        * tree-ssa-dce.c (mark_aliased_reaching_defs_necessary_1): Properly
        handle the dominance check inside a basic-block.

        * gcc.dg/torture/pr58246.c: New testcase.

Index: gcc/tree-ssa-dce.c
===================================================================
*** gcc/tree-ssa-dce.c  (revision 202068)
--- gcc/tree-ssa-dce.c  (working copy)
*************** mark_aliased_reaching_defs_necessary_1 (
*** 574,579 ****
--- 574,584 ----
                      in the references (gcc.c-torture/execute/pr42142.c).
                      The simplest way is to check if the kill dominates
                      the use.  */
+                  /* But when both are in the same block we cannot
+                     easily tell whether we came from a backedge
+                     unless we decide to compute stmt UIDs
+                     (see PR58246).  */
+                  && (basic_block) data != gimple_bb (def_stmt)
                   && dominated_by_p (CDI_DOMINATORS, (basic_block) data,
                                      gimple_bb (def_stmt))
                   && operand_equal_p (ref->ref, lhs, 0))
Index: gcc/testsuite/gcc.dg/torture/pr58246.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr58246.c      (revision 0)
--- gcc/testsuite/gcc.dg/torture/pr58246.c      (working copy)
***************
*** 0 ****
--- 1,21 ----
+ /* { dg-do run } */
+ 
+ extern void abort (void);
+ 
+ int a, b; 
+ 
+ int main ()
+ {
+   int t[2] = {1,1};
+ 
+   for (a = 0; a < 2; a++)
+     {
+       b ^= t[a];
+       t[a] = t[1] = 0;
+     }
+ 
+   if (b != 1)
+     abort ();
+ 
+   return 0;
+ }

Reply via email to