+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
+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
--- /dev/null
+// { dg-do compile }
+// { dg-options "-O2" }
+
+int g;
+
+extern "C" int isnan ();
+
+void foo(float a) {
+ int (*xx)(...);
+ xx = isnan;
+ if (xx(a))
+ g++;
+}
--- /dev/null
+/* { 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();
+}
--- /dev/null
+/* { 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;
+}
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. */
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,
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);
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);
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);
}
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
/* 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;