/* Loop invariant motion.
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Free Software
Foundation, Inc.
-
+
This file is part of GCC.
-
+
GCC is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
later version.
-
+
GCC is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
-
+
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
/* Calls CBCK for each index in memory reference ADDR_P. There are two
kinds situations handled; in each of these cases, the memory reference
and DATA are passed to the callback:
-
+
Access to an array: ARRAY_{RANGE_}REF (base, index). In this case we also
pass the pointer to the index to the callback.
Pointer dereference: INDIRECT_REF (addr). In this case we also pass the
pointer to addr to the callback.
-
+
If the callback returns false, the whole search stops and false is returned.
Otherwise the function returns true after traversing through the whole
reference *ADDR_P. */
/* DATA is a structure containing information associated with a statement
inside LOOP. DEF is one of the operands of this statement.
-
+
Find the outermost loop enclosing LOOP in that value of DEF is invariant
and record this in DATA->max_loop field. If DEF itself is defined inside
this loop as well (i.e. we need to hoist it out of the loop if we want
to hoist the statement represented by DATA), record the statement in that
DEF is defined to the DATA->depends list. Additionally if ADD_COST is true,
add the cost of the computation of DEF to the DATA->cost.
-
+
If DEF is not invariant in LOOP, return false. Otherwise return TRUE. */
static bool
If MUST_PRESERVE_EXEC is true, additionally choose such a loop that
we preserve the fact whether STMT is executed. It also fills other related
information to LIM_DATA (STMT).
-
+
The function returns false if STMT cannot be hoisted outside of the loop it
is defined in, and true otherwise. */
struct lim_aux_data *lim_data = get_lim_data (stmt);
tree val;
ssa_op_iter iter;
-
+
if (must_preserve_exec)
level = ALWAYS_EXECUTED_IN (bb);
else
gimple stmt, stmt1, stmt2;
tree var, name, lhs, type;
tree real_one;
+ gimple_stmt_iterator gsi;
stmt = gsi_stmt (*bsi);
lhs = gimple_assign_lhs (stmt);
/* Replace division stmt with reciprocal and multiply stmts.
The multiply stmt is not invariant, so update iterator
and avoid rescanning. */
- gsi_replace (bsi, stmt1, true);
- gsi_insert_after (bsi, stmt2, GSI_NEW_STMT);
+ gsi = *bsi;
+ gsi_insert_before (bsi, stmt1, GSI_NEW_STMT);
+ gsi_replace (&gsi, stmt2, true);
/* Continue processing with invariant reciprocal statement. */
return stmt1;
if (outermost_invariant_loop (b, loop_containing_stmt (stmt1)) != NULL
&& outermost_invariant_loop (a, loop_containing_stmt (stmt1)) == NULL)
{
+ gimple_stmt_iterator rsi;
+
/* 1 << B */
var = create_tmp_var (TREE_TYPE (a), "shifttmp");
add_referenced_var (var);
SET_USE (use, name);
gimple_cond_set_rhs (use_stmt, build_int_cst_type (TREE_TYPE (name), 0));
- gsi_insert_before (bsi, stmt1, GSI_SAME_STMT);
- propagate_defs_into_debug_stmts (gsi_stmt (*bsi), NULL, NULL);
- gsi_replace (bsi, stmt2, true);
+ /* Don't use gsi_replace here, none of the new assignments sets
+ the variable originally set in stmt. Move bsi to stmt1, and
+ then remove the original stmt, so that we get a chance to
+ retain debug info for it. */
+ rsi = *bsi;
+ gsi_insert_before (bsi, stmt1, GSI_NEW_STMT);
+ gsi_insert_before (&rsi, stmt2, GSI_SAME_STMT);
+ gsi_remove (&rsi, true);
return stmt1;
}
mark_virtual_ops_for_renaming (stmt);
gsi_insert_on_edge (loop_preheader_edge (level), stmt);
- propagate_defs_into_debug_stmts (gsi_stmt (bsi), NULL, NULL);
gsi_remove (&bsi, false);
}
}
return;
gcc_assert (TREE_CODE (op) == SSA_NAME);
-
+
stmt = SSA_NAME_DEF_STMT (op);
if (gimple_nop_p (stmt))
return;
gen_lsm_tmp_name (TREE_OPERAND (ref, 0));
lsm_tmp_name_add ("_RE");
break;
-
+
case IMAGPART_EXPR:
gen_lsm_tmp_name (TREE_OPERAND (ref, 0));
lsm_tmp_name_add ("_IM");