#ifdef HAVE_isl
+#define INCLUDE_MAP
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "cfganal.h"
#include "value-prof.h"
#include "graphite.h"
-#include <map>
/* We always try to use signed 128 bit types, but fall back to smaller types
in case a platform does not provide types of these sizes. In the future we
if (integer_onep (cond_expr))
exit_edge = entry_edge;
else
- exit_edge = create_empty_if_region_on_edge (entry_edge, cond_expr);
+ exit_edge = create_empty_if_region_on_edge (entry_edge,
+ unshare_expr (cond_expr));
return exit_edge;
}
static bool
bb_contains_loop_phi_nodes (basic_block bb)
{
- gcc_assert (EDGE_COUNT (bb->preds) <= 2);
-
- if (bb->preds->length () == 1)
+ if (EDGE_COUNT (bb->preds) != 2)
return false;
unsigned depth = loop_depth (bb->loop_father);
/* Find the iterator which is the latest. */
if (bb1 == bb2)
{
+ gimple *stmt1 = gsi_stmt (gsi1);
+ gimple *stmt2 = gsi_stmt (gsi2);
+
+ if (stmt1 != NULL && stmt2 != NULL)
+ {
+ bool is_phi1 = gimple_code (stmt1) == GIMPLE_PHI;
+ bool is_phi2 = gimple_code (stmt2) == GIMPLE_PHI;
+
+ if (is_phi1 != is_phi2)
+ return is_phi1 ? gsi2 : gsi1;
+ }
+
/* For empty basic blocks gsis point to the end of the sequence. Since
there is no operator== defined for gimple_stmt_iterator and for gsis
not pointing to a valid statement gsi_next would assert. */
void translate_isl_ast_to_gimple::
collect_all_ssa_names (tree new_expr, vec<tree> *vec_ssa)
{
+ if (new_expr == NULL_TREE)
+ return;
/* Rename all uses in new_expr. */
if (TREE_CODE (new_expr) == SSA_NAME)
if (exp == f)
return r;
- /* Fall through... */
+ /* Fall through. */
case tcc_exceptional:
case tcc_unary:
tree scev = scalar_evolution_in_region (region->region, loop, old_name);
/* At this point we should know the exact scev for each
- scalar SSA_NAME used in the scop. */
- gcc_assert (!chrec_contains_undetermined (scev));
+ scalar SSA_NAME used in the scop: all the other scalar
+ SSA_NAMEs should have been translated out of SSA using
+ arrays with one element. */
+ tree new_expr;
+ if (chrec_contains_undetermined (scev))
+ {
+ codegen_error = true;
+ return build_zero_cst (TREE_TYPE (old_name));
+ }
- tree new_expr = chrec_apply_map (scev, iv_map);
+ new_expr = chrec_apply_map (scev, iv_map);
/* The apply should produce an expression tree containing
the uses of the new induction variables. We should be
able to use new_expr instead of the old_name in the newly
generated loop nest. */
- gcc_assert (!chrec_contains_undetermined (new_expr)
- && !tree_contains_chrecs (new_expr, NULL));
+ if (chrec_contains_undetermined (new_expr)
+ || tree_contains_chrecs (new_expr, NULL))
+ {
+ codegen_error = true;
+ return build_zero_cst (TREE_TYPE (old_name));
+ }
if (TREE_CODE (new_expr) == SSA_NAME)
{
b1 = b2;
}
- gcc_assert (b1);
return b1;
}
basic_block old_bb, phi_node_kind phi_kind) const
{
/* For constants the names are the same. */
- if (is_constant (op))
+ if (TREE_CODE (op) != SSA_NAME)
return op;
return get_rename (new_bb, op, old_bb, phi_kind);
fprintf (dump_file, "\n");
}
gsi_insert_earliest (stmts);
- new_phi_args [i] = new_name;
+ new_phi_args[i] = new_expr;
continue;
}
gcc_assert (!bb_contains_loop_close_phi_nodes (bb));
+ /* TODO: Handle cond phi nodes with more than 2 predecessors. */
+ if (EDGE_COUNT (bb->preds) != 2)
+ return false;
+
if (dump_file)
fprintf (dump_file, "[codegen] copying cond phi nodes in bb_%d.\n",
new_bb->index);
- /* Cond phi nodes should have exactly two arguments. */
- gcc_assert (2 == EDGE_COUNT (bb->preds));
-
for (gphi_iterator psi = gsi_start_phis (bb); !gsi_end_p (psi);
gsi_next (&psi))
{