]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* tree-vrp.c (simplify_stmt_for_jump_threading): Try to
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 21 Aug 2013 12:36:36 +0000 (12:36 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 21 Aug 2013 12:36:36 +0000 (12:36 +0000)
simplify assignments too.  If the RHS collapses to a singleton
range, then return the value for the range.

* gcc.dg/tree-ssa/ssa-vrp-thread-1.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@201898 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/ssa-vrp-thread-1.c [new file with mode: 0644]
gcc/tree-vrp.c

index b20b9fa4e517d454bd2255e7d60de2d25455dd08..d98dc5fa555944f559977c26b732571cd1530817 100644 (file)
@@ -1,3 +1,9 @@
+2013-08-21  Jeff Law  <law@redhat.com>
+
+       * tree-vrp.c (simplify_stmt_for_jump_threading): Try to
+       simplify assignments too.  If the RHS collapses to a singleton
+       range, then return the value for the range.
+
 2013-08-21  Kirill Yukhin  <kirill.yukhin@intel.com>
 
         * config/i386/sse.md (V16): Rename to...
index 9802c29f4889946eaa52ab23fa2b17b58c26a6c5..e0fb86111abe92042efd05c27096973ff419d6e3 100644 (file)
@@ -1,3 +1,7 @@
+2013-08-21  Jeff Law  <law@redhat.com>
+
+       * gcc.dg/tree-ssa/ssa-vrp-thread-1.c: New test.
+
 2013-08-21  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/56134
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-vrp-thread-1.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-vrp-thread-1.c
new file mode 100644 (file)
index 0000000..9d9473e
--- /dev/null
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp1-details" } */
+
+
+struct basic_block_def;
+typedef struct basic_block_def *basic_block;
+enum gimple_code
+{
+  LAST_AND_UNUSED_GIMPLE_CODE
+};
+struct omp_region
+{
+  struct omp_region *outer;
+  basic_block cont;
+};
+void
+build_omp_regions_1 (basic_block bb, struct omp_region *parent,
+                    unsigned char single_tree, enum gimple_code code)
+{
+  if (code == 25)
+    parent = parent->outer;
+  else if (code == 42)
+    parent->cont = bb;
+  if (single_tree && !parent)
+    return;
+  oof ();
+}
+
+/* { dg-final { scan-tree-dump-times "Threaded" 1 "vrp1" }  } */
+/* { dg-final { cleanup-tree-dump "vrp1" } } */
+
index ff82591f5f476b557e7b5ebec5fb34994bd4bc9f..48b9f7a072cc848b9ba5b365bc4ca444dce58166 100644 (file)
@@ -9273,15 +9273,27 @@ static vec<tree> equiv_stack;
 static tree
 simplify_stmt_for_jump_threading (gimple stmt, gimple within_stmt)
 {
-  /* We only use VRP information to simplify conditionals.  This is
-     overly conservative, but it's unclear if doing more would be
-     worth the compile time cost.  */
-  if (gimple_code (stmt) != GIMPLE_COND)
-    return NULL;
+  if (gimple_code (stmt) == GIMPLE_COND)
+    return vrp_evaluate_conditional (gimple_cond_code (stmt),
+                                    gimple_cond_lhs (stmt),
+                                    gimple_cond_rhs (stmt), within_stmt);
+
+  if (gimple_code (stmt) == GIMPLE_ASSIGN)
+    {
+      value_range_t new_vr = VR_INITIALIZER;
+      tree lhs = gimple_assign_lhs (stmt);
+
+      if (TREE_CODE (lhs) == SSA_NAME
+         && (INTEGRAL_TYPE_P (TREE_TYPE (lhs))
+             || POINTER_TYPE_P (TREE_TYPE (lhs))))
+       {
+         extract_range_from_assignment (&new_vr, stmt);
+         if (range_int_cst_singleton_p (&new_vr))
+           return new_vr.min;
+       }
+    }
 
-  return vrp_evaluate_conditional (gimple_cond_code (stmt),
-                                  gimple_cond_lhs (stmt),
-                                  gimple_cond_rhs (stmt), within_stmt);
+  return NULL_TREE;
 }
 
 /* Blocks which have more than one predecessor and more than