#include "diagnostic.h"
#include "tree-pretty-print.h"
#include "tree-flow.h"
-#include "toplev.h"
#include "tree-dump.h"
#include "timevar.h"
#include "cfgloop.h"
/* Make sure that the loops in the SESE_LOOP_NEST are ordered. It
can be the case that an inner loop is inserted before an outer
loop. To avoid this, semi-sort once. */
- for (i = 0; VEC_iterate (loop_p, SESE_LOOP_NEST (region), i, loop0); i++)
+ FOR_EACH_VEC_ELT (loop_p, SESE_LOOP_NEST (region), i, loop0)
{
if (VEC_length (loop_p, SESE_LOOP_NEST (region)) == i + 1)
break;
substitution map RENAME_MAP, inserting the gimplification code at
GSI_TGT, for the translation REGION, with the original copied
statement in LOOP, and using the induction variable renaming map
- IV_MAP. */
+ IV_MAP. Returns true when something has been renamed. */
-static void
+static bool
rename_uses (gimple copy, htab_t rename_map, gimple_stmt_iterator *gsi_tgt,
sese region, loop_p loop, VEC (tree, heap) *iv_map)
{
use_operand_p use_p;
ssa_op_iter op_iter;
+ bool changed = false;
if (is_gimple_debug (copy))
{
else
gcc_unreachable ();
- return;
+ return false;
}
FOR_EACH_SSA_USE_OPERAND (use_p, copy, op_iter, SSA_OP_ALL_USES)
|| SSA_NAME_IS_DEFAULT_DEF (old_name))
continue;
+ changed = true;
new_expr = get_rename (rename_map, old_name);
if (new_expr)
{
/* Replace the old_name with the new_expr. */
new_expr = force_gimple_operand (unshare_expr (new_expr), &stmts,
- true, NULL);
+ true, NULL_TREE);
gsi_insert_seq_before (gsi_tgt, stmts, GSI_SAME_STMT);
replace_exp (use_p, new_expr);
+
+ if (TREE_CODE (new_expr) == INTEGER_CST
+ && is_gimple_assign (copy))
+ {
+ tree rhs = gimple_assign_rhs1 (copy);
+
+ if (TREE_CODE (rhs) == ADDR_EXPR)
+ recompute_tree_invariant_for_addr_expr (rhs);
+ }
+
set_rename (rename_map, old_name, new_expr);
}
+
+ return changed;
}
/* Duplicates the statements of basic block BB into basic block NEW_BB
set_rename (rename_map, old_name, new_name);
}
- rename_uses (copy, rename_map, &gsi_tgt, region, loop, iv_map);
+ if (rename_uses (copy, rename_map, &gsi_tgt, region, loop, iv_map))
+ fold_stmt_inplace (copy);
update_stmt (copy);
}