targhooks.c (default_except_unwind_info): Remove MUST_USE_SJLJ_EXCEPTIONS case.
[platform/upstream/gcc.git] / gcc / tree-if-conv.c
index 86b8f26..fc65845 100644 (file)
@@ -533,7 +533,7 @@ write_memrefs_written_at_least_once (gimple stmt,
 
   for (i = 0; VEC_iterate (data_reference_p, drs, i, a); i++)
     if (DR_STMT (a) == stmt
-       && !DR_IS_READ (a))
+       && DR_IS_WRITE (a))
       {
        bool found = false;
        int x = DR_WRITTEN_AT_LEAST_ONCE (a);
@@ -546,7 +546,7 @@ write_memrefs_written_at_least_once (gimple stmt,
 
        for (j = 0; VEC_iterate (data_reference_p, drs, j, b); j++)
          if (DR_STMT (b) != stmt
-             && !DR_IS_READ (b)
+             && DR_IS_WRITE (b)
              && same_data_refs_base_objects (a, b))
            {
              tree cb = bb_predicate (gimple_bb (DR_STMT (b)));
@@ -915,7 +915,7 @@ predicate_bbs (loop_p loop)
 
            case GIMPLE_COND:
              {
-               tree c2;
+               tree c2, tem;
                edge true_edge, false_edge;
                location_t loc = gimple_location (stmt);
                tree c = fold_build2_loc (loc, gimple_cond_code (stmt),
@@ -928,10 +928,13 @@ predicate_bbs (loop_p loop)
                                                     &true_edge, &false_edge);
 
                /* If C is true, then TRUE_EDGE is taken.  */
-               add_to_dst_predicate_list (loop, true_edge, cond, c);
+               add_to_dst_predicate_list (loop, true_edge, cond, unshare_expr (c));
 
                /* If C is false, then FALSE_EDGE is taken.  */
                c2 = invert_truthvalue_loc (loc, unshare_expr (c));
+               tem = canonicalize_cond_expr_cond (c2);
+               if (tem)
+                 c2 = tem;
                add_to_dst_predicate_list (loop, false_edge, cond, c2);
 
                cond = NULL_TREE;
@@ -1221,7 +1224,7 @@ predicate_scalar_phi (gimple phi, tree cond,
 {
   gimple new_stmt;
   basic_block bb;
-  tree rhs, res, arg;
+  tree rhs, res, arg, scev;
 
   gcc_assert (gimple_code (phi) == GIMPLE_PHI
              && gimple_phi_num_args (phi) == 2);
@@ -1233,8 +1236,12 @@ predicate_scalar_phi (gimple phi, tree cond,
 
   bb = gimple_bb (phi);
 
-  arg = degenerate_phi_result (phi);
-  if (arg)
+  if ((arg = degenerate_phi_result (phi))
+      || ((scev = analyze_scalar_evolution (gimple_bb (phi)->loop_father,
+                                           res))
+         && !chrec_contains_undetermined (scev)
+         && scev != res
+         && (arg = gimple_phi_arg_def (phi, 0))))
     rhs = arg;
   else
     {