]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: [multiple changes]
authorRichard Biener <rguenther@suse.de>
Tue, 6 May 2014 09:02:08 +0000 (09:02 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 6 May 2014 09:02:08 +0000 (09:02 +0000)
2014-05-06  Richard Biener  <rguenther@suse.de>

Backport from mainline
2014-04-17  Richard Biener  <rguenther@suse.de>

PR middle-end/60849
* tree-ssa-propagate.c (valid_gimple_rhs_p): Only allow effective
boolean results for comparisons.

* g++.dg/opt/pr60849.C: New testcase.

2014-04-07  Richard Biener  <rguenther@suse.de>

PR tree-optimization/60766
* tree-ssa-loop-ivopts.c (cand_value_at): Compute in an
unsigned type.
(may_eliminate_iv): Convert cand_value_at result to desired
type.

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

2014-04-23  Richard Biener  <rguenther@suse.de>

PR tree-optimization/60903
* tree-ssa-loop-im.c (execute_sm_if_changed): Properly apply
IRREDUCIBLE_LOOP loop flags to newly created BBs and edges.

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

From-SVN: r210099

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr60849.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr60766.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr60903.c [new file with mode: 0644]
gcc/tree-ssa-loop-im.c
gcc/tree-ssa-loop-ivopts.c
gcc/tree-ssa-propagate.c

index 1058b8fb0051b1f1702f43df5a183de20ce69e2c..b70d476113b88a57f5ca791bffeb47f293420f1b 100644 (file)
@@ -1,3 +1,26 @@
+2014-05-06  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2014-04-17  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/60849
+       * tree-ssa-propagate.c (valid_gimple_rhs_p): Only allow effective
+       boolean results for comparisons.
+
+       2014-04-07  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/60766
+       * tree-ssa-loop-ivopts.c (cand_value_at): Compute in an
+       unsigned type.
+       (may_eliminate_iv): Convert cand_value_at result to desired
+       type.
+
+       2014-04-23  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/60903
+       * tree-ssa-loop-im.c (execute_sm_if_changed): Properly apply
+       IRREDUCIBLE_LOOP loop flags to newly created BBs and edges.
+
 2014-05-05  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
index ab19c0851ffaa9efcb82e3c72f9f506c47947788..a81e46eee898153d0e27ec90cc390db26ccdda52 100644 (file)
@@ -1,3 +1,21 @@
+2014-05-06  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2014-04-17  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/60849
+       * g++.dg/opt/pr60849.C: New testcase.
+
+       2014-04-07  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/60766
+       * gcc.dg/torture/pr60766.c: New testcase.
+
+       2014-04-23  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/60903
+       * gcc.dg/torture/pr60903.c: New testcase.
+
 2014-05-05  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
diff --git a/gcc/testsuite/g++.dg/opt/pr60849.C b/gcc/testsuite/g++.dg/opt/pr60849.C
new file mode 100644 (file)
index 0000000..52d8826
--- /dev/null
@@ -0,0 +1,13 @@
+// { dg-do compile }
+// { dg-options "-O2" }
+
+int g;
+
+extern "C" int isnan ();
+
+void foo(float a) {
+  int (*xx)(...);
+  xx = isnan;
+  if (xx(a))
+    g++;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr60766.c b/gcc/testsuite/gcc.dg/torture/pr60766.c
new file mode 100644 (file)
index 0000000..6f16e3b
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do run } */
+
+int m = 9;
+
+int main()
+{
+  int n, x;
+
+  n = m;
+  for (x = 0; x <= n; x++)
+    if (n == x + (x + 1) + (x + 2))
+      return 0;
+
+  __builtin_abort();
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr60903.c b/gcc/testsuite/gcc.dg/torture/pr60903.c
new file mode 100644 (file)
index 0000000..5d93ae3
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+
+extern int a, b, k, q;
+
+void
+foo ()
+{
+  if (a)
+    {
+      while (q)
+       {
+       lbl:
+         if (a)
+           {
+             a = 0;
+             goto lbl;
+           }
+       }
+      b = k;
+    }
+  goto lbl;
+}
index 72ed570dc555518b18db88f92d4b27b26ef01c04..619750721eaee6a5f5716eed1a78cf63903a46ef 100644 (file)
@@ -2067,6 +2067,7 @@ execute_sm_if_changed (edge ex, tree mem, tree tmp_var, tree flag)
   gimple_stmt_iterator gsi;
   gimple stmt;
   struct prev_flag_edges *prev_edges = (struct prev_flag_edges *) ex->aux;
+  bool irr = ex->flags & EDGE_IRREDUCIBLE_LOOP;
 
   /* ?? Insert store after previous store if applicable.  See note
      below.  */
@@ -2081,8 +2082,9 @@ execute_sm_if_changed (edge ex, tree mem, tree tmp_var, tree flag)
   old_dest = ex->dest;
   new_bb = split_edge (ex);
   then_bb = create_empty_bb (new_bb);
-  if (current_loops && new_bb->loop_father)
-    add_bb_to_loop (then_bb, new_bb->loop_father);
+  if (irr)
+    then_bb->flags = BB_IRREDUCIBLE_LOOP;
+  add_bb_to_loop (then_bb, new_bb->loop_father);
 
   gsi = gsi_start_bb (new_bb);
   stmt = gimple_build_cond (NE_EXPR, flag, boolean_false_node,
@@ -2094,9 +2096,12 @@ execute_sm_if_changed (edge ex, tree mem, tree tmp_var, tree flag)
   stmt = gimple_build_assign (unshare_expr (mem), tmp_var);
   gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
 
-  make_edge (new_bb, then_bb, EDGE_TRUE_VALUE);
-  make_edge (new_bb, old_dest, EDGE_FALSE_VALUE);
-  then_old_edge = make_edge (then_bb, old_dest, EDGE_FALLTHRU);
+  make_edge (new_bb, then_bb,
+            EDGE_TRUE_VALUE | (irr ? EDGE_IRREDUCIBLE_LOOP : 0));
+  make_edge (new_bb, old_dest,
+            EDGE_FALSE_VALUE | (irr ? EDGE_IRREDUCIBLE_LOOP : 0));
+  then_old_edge = make_edge (then_bb, old_dest,
+                            EDGE_FALLTHRU | (irr ? EDGE_IRREDUCIBLE_LOOP : 0));
 
   set_immediate_dominator (CDI_DOMINATORS, then_bb, new_bb);
 
index 2940bf100447874d98bab4fc8265ae8713ecc603..17dd478a653fcdd7faf4ee9b5913c19672b3df4d 100644 (file)
@@ -4236,8 +4236,10 @@ cand_value_at (struct loop *loop, struct iv_cand *cand, gimple at, tree niter,
   tree steptype = type;
   if (POINTER_TYPE_P (type))
     steptype = sizetype;
+  steptype = unsigned_type_for (type);
 
-  tree_to_aff_combination (iv->step, steptype, &step);
+  tree_to_aff_combination (iv->step, TREE_TYPE (iv->step), &step);
+  aff_combination_convert (&step, steptype);
   tree_to_aff_combination (niter, TREE_TYPE (niter), &nit);
   aff_combination_convert (&nit, steptype);
   aff_combination_mult (&nit, &step, &delta);
@@ -4245,6 +4247,8 @@ cand_value_at (struct loop *loop, struct iv_cand *cand, gimple at, tree niter,
     aff_combination_add (&delta, &step);
 
   tree_to_aff_combination (iv->base, type, val);
+  if (!POINTER_TYPE_P (type))
+    aff_combination_convert (val, steptype);
   aff_combination_add (val, &delta);
 }
 
@@ -4623,7 +4627,8 @@ may_eliminate_iv (struct ivopts_data *data,
 
   cand_value_at (loop, cand, use->stmt, desc->niter, &bnd);
 
-  *bound = aff_combination_to_tree (&bnd);
+  *bound = fold_convert (TREE_TYPE (cand->iv->base),
+                        aff_combination_to_tree (&bnd));
   *comp = iv_elimination_compare (data, use);
 
   /* It is unlikely that computing the number of iterations using division
index afd7233c213213aa15baee22a5aa7da0b89f3c5c..d39d97a1751dc6fdd2cb23bdedfda6c22a609ce1 100644 (file)
@@ -556,8 +556,18 @@ valid_gimple_rhs_p (tree expr)
       /* All constants are ok.  */
       break;
 
-    case tcc_binary:
     case tcc_comparison:
+      /* GENERIC allows comparisons with non-boolean types, reject
+         those for GIMPLE.  Let vector-typed comparisons pass - rules
+        for GENERIC and GIMPLE are the same here.  */
+      if (!(INTEGRAL_TYPE_P (TREE_TYPE (expr))
+           && (TREE_CODE (TREE_TYPE (expr)) == BOOLEAN_TYPE
+               || TYPE_PRECISION (TREE_TYPE (expr)) == 1))
+         && TREE_CODE (TREE_TYPE (expr)) != VECTOR_TYPE)
+       return false;
+
+      /* Fallthru.  */
+    case tcc_binary:
       if (!is_gimple_val (TREE_OPERAND (expr, 0))
          || !is_gimple_val (TREE_OPERAND (expr, 1)))
        return false;