re PR c/61779 (gcc -Og fails with impossible constraint on legal C code)
authorRichard Biener <rguenther@suse.de>
Mon, 14 Jul 2014 13:52:38 +0000 (13:52 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 14 Jul 2014 13:52:38 +0000 (13:52 +0000)
2014-07-14  Richard Biener  <rguenther@suse.de>

PR tree-optimization/61779
* tree-ssa-copy.c (copy_prop_visit_cond_stmt): Always try
simplifying a condition.

* gcc.dg/tree-ssa/ssa-copyprop-2.c: New testcase.

From-SVN: r212521

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/ssa-copyprop-2.c [new file with mode: 0644]
gcc/tree-ssa-copy.c

index 04cece4ee76b8186b24cd6b9adbe1cb2111b1ea3..65a6b5ecb5ef6d838c75473dd6a0342f050dd118 100644 (file)
@@ -1,3 +1,9 @@
+2014-07-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/61779
+       * tree-ssa-copy.c (copy_prop_visit_cond_stmt): Always try
+       simplifying a condition.
+
 2014-07-14  Richard Biener  <rguenther@suse.de>
 
        * builtins.c (c_strlen): Make only_value == 2 really only
index a6483a68ec1def221469546a134f298e51129298..0a7e5673a78df5c8e06f9fee0ea8b852159833e4 100644 (file)
@@ -1,3 +1,8 @@
+2014-07-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/61779
+       * gcc.dg/tree-ssa/ssa-copyprop-2.c: New testcase.
+
 2014-07-14  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/61786
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-copyprop-2.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-copyprop-2.c
new file mode 100644 (file)
index 0000000..9757013
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-Og -fdump-tree-optimized" } */
+
+extern long long __sdt_unsp;
+void
+f(void)
+{
+  for (;;)
+    __asm__ ("%0" :: "i" (((!__extension__ (__builtin_constant_p ((((unsigned long long) (__typeof (__builtin_choose_expr (((__builtin_classify_type (0) + 3) & -4) == 4, (0), 0U))) __sdt_unsp) ) == 0) )) ? 1 : -1) ));
+}
+
+/* { dg-final { scan-tree-dump-not "PHI" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
index b8df7a8f23c63032cff6938bcf08c3c04f84f533..06d98df00fc115220549e7e62c1ca7c2b82dec43 100644 (file)
@@ -237,38 +237,26 @@ copy_prop_visit_cond_stmt (gimple stmt, edge *taken_edge_p)
   enum ssa_prop_result retval = SSA_PROP_VARYING;
   location_t loc = gimple_location (stmt);
 
-  tree op0 = gimple_cond_lhs (stmt);
-  tree op1 = gimple_cond_rhs (stmt);
+  tree op0 = valueize_val (gimple_cond_lhs (stmt));
+  tree op1 = valueize_val (gimple_cond_rhs (stmt));
 
-  /* The only conditionals that we may be able to compute statically
-     are predicates involving two SSA_NAMEs.  */
-  if (TREE_CODE (op0) == SSA_NAME && TREE_CODE (op1) == SSA_NAME)
+  /* See if we can determine the predicate's value.  */
+  if (dump_file && (dump_flags & TDF_DETAILS))
     {
-      op0 = valueize_val (op0);
-      op1 = valueize_val (op1);
-
-      /* See if we can determine the predicate's value.  */
-      if (dump_file && (dump_flags & TDF_DETAILS))
-       {
-         fprintf (dump_file, "Trying to determine truth value of ");
-         fprintf (dump_file, "predicate ");
-         print_gimple_stmt (dump_file, stmt, 0, 0);
-       }
+      fprintf (dump_file, "Trying to determine truth value of ");
+      fprintf (dump_file, "predicate ");
+      print_gimple_stmt (dump_file, stmt, 0, 0);
+    }
 
-      /* We can fold COND and get a useful result only when we have
-        the same SSA_NAME on both sides of a comparison operator.  */
-      if (op0 == op1)
-       {
-         tree folded_cond = fold_binary_loc (loc, gimple_cond_code (stmt),
-                                          boolean_type_node, op0, op1);
-         if (folded_cond)
-           {
-             basic_block bb = gimple_bb (stmt);
-             *taken_edge_p = find_taken_edge (bb, folded_cond);
-             if (*taken_edge_p)
-               retval = SSA_PROP_INTERESTING;
-           }
-       }
+  /* Fold COND and see whether we get a useful result.  */
+  tree folded_cond = fold_binary_loc (loc, gimple_cond_code (stmt),
+                                     boolean_type_node, op0, op1);
+  if (folded_cond)
+    {
+      basic_block bb = gimple_bb (stmt);
+      *taken_edge_p = find_taken_edge (bb, folded_cond);
+      if (*taken_edge_p)
+       retval = SSA_PROP_INTERESTING;
     }
 
   if (dump_file && (dump_flags & TDF_DETAILS) && *taken_edge_p)