]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
common.opt (fkeep-gc-roots-live): New undocumented option.
authorIan Lance Taylor <iant@google.com>
Wed, 27 Jan 2016 17:42:47 +0000 (17:42 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Wed, 27 Jan 2016 17:42:47 +0000 (17:42 +0000)
gcc/:
* common.opt (fkeep-gc-roots-live): New undocumented option.
* tree-ssa-loop-ivopts.c (add_candidate_1): If
-fkeep-gc-roots-live, skip pointers.
(add_iv_candidate_for_biv): Handle add_candidate_1 returning
NULL.

gcc/testsuite/:
* gcc.dg/tree-ssa/ivopt_5.c: New test.

From-SVN: r232888

gcc/ChangeLog
gcc/common.opt
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/ivopt_5.c [new file with mode: 0644]
gcc/tree-ssa-loop-ivopts.c

index ea590888d418f4511eac1d6939fadca845bf23d8..60322afb7a6d2a05b7bb5a22d2e2dd207a184061 100644 (file)
@@ -1,3 +1,11 @@
+2016-01-27  Ian Lance Taylor  <iant@google.com>
+
+       * common.opt (fkeep-gc-roots-live): New undocumented option.
+       * tree-ssa-loop-ivopts.c (add_candidate_1): If
+       -fkeep-gc-roots-live, skip pointers.
+       (add_iv_candidate_for_biv): Handle add_candidate_1 returning
+       NULL.
+
 2016-01-27  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/69512
index 0f2587aa4429924c3490f37050bc4cb467b11812..520fa9c9dd57701d4707a4bd746f0d384164a9eb 100644 (file)
@@ -1380,6 +1380,10 @@ Common Report Var(flag_hoist_adjacent_loads) Optimization
 Enable hoisting adjacent loads to encourage generating conditional move
 instructions.
 
+fkeep-gc-roots-live
+Common Undocumented Report Var(flag_keep_gc_roots_live) Optimization
+; Always keep a pointer to a live memory block
+
 floop-parallelize-all
 Common Report Var(flag_loop_parallelize_all) Optimization
 Mark all loops as parallel.
index 98bb775ccac8ebdbe5d3b2a5d0da0723e28f4af2..b3af22c448d104d611474b0c06b5f88cee52e403 100644 (file)
@@ -1,3 +1,7 @@
+2016-01-27  Ian Lance Taylor  <iant@google.com>
+
+       * gcc.dg/tree-ssa/ivopt_5.c: New test.
+
 2016-01-27  Ryan Burn  <contact@rnburn.com>
 
        PR cilkplus/69267
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ivopt_5.c b/gcc/testsuite/gcc.dg/tree-ssa/ivopt_5.c
new file mode 100644 (file)
index 0000000..b0d4166
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-options "-O2 -fdump-tree-ivopts -fkeep-gc-roots-live" } */
+
+/* Only integer ivopts here when using -fkeep-gc-roots-live.   */
+
+void foo (char *pstart, int n)
+{
+  char *p;
+  char *pend = pstart + n;
+
+  for (p = pstart; p < pend; p++)
+    *p = 1;
+}
+
+void foo1 (char *pstart, int n)
+{
+  char *p;
+  char *pend = pstart + n;
+
+  for (p = pstart; p != pend; p++)
+    *p = 1;
+}
+
+/* { dg-final { scan-tree-dump-times "ivtmp.\[0-9_\]* = PHI <\[^0\]" 0 "ivopts"} } */
index 3faed930dc2ed8b2e497501060c02addd7909408..4026d28bb2c9cf6d4b88eb750f6ae41c82a3f251 100644 (file)
@@ -2815,6 +2815,16 @@ add_candidate_1 (struct ivopts_data *data,
   struct iv_cand *cand = NULL;
   tree type, orig_type;
 
+  /* -fkeep-gc-roots-live means that we have to keep a real pointer
+     live, but the ivopts code may replace a real pointer with one
+     pointing before or after the memory block that is then adjusted
+     into the memory block during the loop.  FIXME: It would likely be
+     better to actually force the pointer live and still use ivopts;
+     for example, it would be enough to write the pointer into memory
+     and keep it there until after the loop.  */
+  if (flag_keep_gc_roots_live && POINTER_TYPE_P (TREE_TYPE (base)))
+    return NULL;
+
   /* For non-original variables, make sure their values are computed in a type
      that does not invoke undefined behavior on overflows (since in general,
      we cannot prove that these induction variables are non-wrapping).  */
@@ -3083,8 +3093,11 @@ add_iv_candidate_for_biv (struct ivopts_data *data, struct iv *iv)
          cand = add_candidate_1 (data,
                                  iv->base, iv->step, true, IP_ORIGINAL, NULL,
                                  SSA_NAME_DEF_STMT (def));
-         cand->var_before = iv->ssa_name;
-         cand->var_after = def;
+         if (cand)
+           {
+             cand->var_before = iv->ssa_name;
+             cand->var_after = def;
+           }
        }
       else
        gcc_assert (gimple_bb (phi) == data->current_loop->header);