re PR tree-optimization/65217 (__builtin_unreachable in if statement causes bad assem...
authorJeff Law <law@redhat.com>
Tue, 28 Apr 2015 04:01:28 +0000 (22:01 -0600)
committerJeff Law <law@gcc.gnu.org>
Tue, 28 Apr 2015 04:01:28 +0000 (22:01 -0600)
PR tree-optimization/65217
* tree-ssa-dom.c (record_equality): Given two SSA_NAMEs, if just one
of them has a single use, make sure it is the LHS of the implied
copy.

        PR tree-optimization/65217
* gcc.target/i386/pr65217.c: Remove XFAIL.

From-SVN: r222499

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr65217.c
gcc/tree-ssa-dom.c

index fff0015a15fc7a036233d1ad3d9984b6555af56a..1a82f17a97fb7a567a45cb6d94d34671daeafa28 100644 (file)
@@ -1,3 +1,10 @@
+2015-04-27  Jeff Law  <law@redhat.com>
+
+       PR tree-optimization/65217
+       * tree-ssa-dom.c (record_equality): Given two SSA_NAMEs, if just one
+       of them has a single use, make sure it is the LHS of the implied
+       copy.
+
 2015-04-28  Alan Modra  <amodra@gmail.com>
 
        PR target/65810
index 67bdd69ddf0eb06abe3b1596ffb9a18c974e29e6..0fc23843520b31318ff8023e2f43050bce0e6b08 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-27  Jeff Law <law@redhat.com>
+
+        PR tree-optimization/65217
+       * gcc.target/i386/pr65217.c: Remove XFAIL.
+
 2015-04-27  Andre Vehreschild  <vehre@gmx.de>
 
        PR fortran/60322
index 3f495b21f29a89906511eae0237f1ceca7083702..d5c9be5b9ef22668ce5c8762adc3f361a050eff0 100644 (file)
@@ -1,7 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-O" } */
-/* { dg-final { scan-assembler-not "negl" { xfail *-*-* } } } */
-/* { dg-final { scan-assembler-not "andl" { xfail *-*-* } } } */
+/* { dg-final { scan-assembler-not "negl" } } */
+/* { dg-final { scan-assembler-not "andl" } } */
 
 int 
 test(int n)
index a67b4e447ac45c92008a656c99bb043c4dc15d52..c7d427be22ec007d40b4e9ff9c323478ea4294f2 100644 (file)
@@ -1762,6 +1762,20 @@ record_equality (tree x, tree y)
   if (tree_swap_operands_p (x, y, false))
     std::swap (x, y);
 
+  /* Most of the time tree_swap_operands_p does what we want.  But there's
+     cases where we we know one operand is better for copy propagation than
+     the other.  Given no other code cares about ordering of equality
+     comparison operators for that purpose, we just handle the special cases
+     here.  */
+  if (TREE_CODE (x) == SSA_NAME && TREE_CODE (y) == SSA_NAME)
+    {
+      /* If one operand is a single use operand, then make it
+        X.  This will preserve its single use properly and if this
+        conditional is eliminated, the computation of X can be
+        eliminated as well.  */
+      if (has_single_use (y) && ! has_single_use (x))
+       std::swap (x, y);
+    }
   if (TREE_CODE (x) == SSA_NAME)
     prev_x = SSA_NAME_VALUE (x);
   if (TREE_CODE (y) == SSA_NAME)