- if (num_iterations > 2 && dump_file && (dump_flags & TDF_STATS))
- fprintf (dump_file, "insert required %d iterations\n", num_iterations);
-}
-
-
-/* Return true if VAR is an SSA variable with no defining statement in
- this procedure, *AND* isn't a live-on-entry parameter. */
-
-static bool
-is_undefined_value (tree expr)
-{
- return (TREE_CODE (expr) == SSA_NAME
- && IS_EMPTY_STMT (SSA_NAME_DEF_STMT (expr))
- /* PARM_DECLs and hard registers are always defined. */
- && TREE_CODE (SSA_NAME_VAR (expr)) != PARM_DECL);
-}
-
-
-/* Given an SSA variable VAR and an expression EXPR, compute the value
- number for EXPR and create a value handle (VAL) for it. If VAR and
- EXPR are not the same, associate VAL with VAR. Finally, add VAR to
- S1 and its value handle to S2, and to the maximal set if
- ADD_TO_MAXIMAL is true.
-
- VUSES represent the virtual use operands associated with EXPR (if
- any). */
-
-static inline void
-add_to_sets (tree var, tree expr, tree stmt, bitmap_set_t s1,
- bitmap_set_t s2)
-{
- tree val = vn_lookup_or_add (expr, stmt);
-
- /* VAR and EXPR may be the same when processing statements for which
- we are not computing value numbers (e.g., non-assignments, or
- statements that make aliased stores). In those cases, we are
- only interested in making VAR available as its own value. */
- if (var != expr)
- vn_add (var, val);
-
- if (s1)
- bitmap_insert_into_set (s1, var);
-
- /* PHI nodes can't go in the maximal sets because they are not in
- TMP_GEN, so it is possible to get into non-monotonic situations
- during ANTIC calculation, because it will *add* bits. */
- if (!in_fre && TREE_CODE (SSA_NAME_DEF_STMT (var)) != PHI_NODE)
- bitmap_value_insert_into_set (maximal_set, var);
- bitmap_value_insert_into_set (s2, var);
-}
-
-/* Find existing value expression that is the same as T,
- and return it if it exists. */
-
-static inline tree
-find_existing_value_expr (tree t, tree stmt)
-{
- bitmap_iterator bi;
- unsigned int bii;
- tree vh;
- bitmap_set_t exprset;
-
- if (REFERENCE_CLASS_P (t))
- vh = vn_lookup (t, stmt);
- else
- vh = vn_lookup (t, NULL);
-
- if (!vh)
- return NULL;
- exprset = VALUE_HANDLE_EXPR_SET (vh);
- FOR_EACH_EXPR_ID_IN_SET (exprset, bii, bi)
- {
- tree efi = expression_for_id (bii);
- if (expressions_equal_p (t, efi))
- return efi;
- }
- return NULL;
-}
-
-/* Given a unary or binary expression EXPR, create and return a new
- expression with the same structure as EXPR but with its operands
- replaced with the value handles of each of the operands of EXPR.
-
- VUSES represent the virtual use operands associated with EXPR (if
- any). Insert EXPR's operands into the EXP_GEN set for BLOCK. */
-
-static inline tree
-create_value_expr_from (tree expr, basic_block block, tree stmt)
-{
- int i;
- enum tree_code code = TREE_CODE (expr);
- tree vexpr;
- alloc_pool pool = NULL;
- tree efi;
-
- gcc_assert (TREE_CODE_CLASS (code) == tcc_unary
- || TREE_CODE_CLASS (code) == tcc_binary
- || TREE_CODE_CLASS (code) == tcc_comparison
- || TREE_CODE_CLASS (code) == tcc_reference
- || TREE_CODE_CLASS (code) == tcc_expression
- || TREE_CODE_CLASS (code) == tcc_vl_exp
- || TREE_CODE_CLASS (code) == tcc_exceptional
- || TREE_CODE_CLASS (code) == tcc_declaration);
-
- if (TREE_CODE_CLASS (code) == tcc_unary)
- pool = unary_node_pool;
- else if (TREE_CODE_CLASS (code) == tcc_reference)
- pool = reference_node_pool;
- else if (TREE_CODE_CLASS (code) == tcc_binary)
- pool = binary_node_pool;
- else if (TREE_CODE_CLASS (code) == tcc_comparison)
- pool = comparison_node_pool;
- else
- gcc_assert (code == CALL_EXPR);
-
- if (code == CALL_EXPR)
- vexpr = temp_copy_call_expr (expr);
- else
- {
- vexpr = (tree) pool_alloc (pool);
- memcpy (vexpr, expr, tree_size (expr));
- }
-
- for (i = 0; i < TREE_OPERAND_LENGTH (expr); i++)
- {
- tree val, op;
-
- op = TREE_OPERAND (expr, i);
- if (op == NULL_TREE)
- continue;
-
- /* Recursively value-numberize reference ops and tree lists. */
- if (REFERENCE_CLASS_P (op))
- {
- tree tempop = create_value_expr_from (op, block, stmt);
- op = tempop ? tempop : op;
- val = vn_lookup_or_add (op, stmt);
- }
- else
- /* Create a value handle for OP and add it to VEXPR. */
- val = vn_lookup_or_add (op, NULL);
-
- if (!is_undefined_value (op) && TREE_CODE (op) != TREE_LIST)
- bitmap_value_insert_into_set (EXP_GEN (block), op);
-
- if (TREE_CODE (val) == VALUE_HANDLE)
- TREE_TYPE (val) = TREE_TYPE (TREE_OPERAND (vexpr, i));
-
- TREE_OPERAND (vexpr, i) = val;
- }
- efi = find_existing_value_expr (vexpr, stmt);
- if (efi)
- return efi;
- get_or_alloc_expression_id (vexpr);
- return vexpr;