- || TREE_CODE (SSA_NAME_DEF_STMT (op)) != PHI_NODE)
- bitmap_value_insert_into_set (maximal_set, op);
- }
-}
-
-
-/* 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, VEC(tree, gc) *vuses, bitmap_set_t s1,
- bitmap_set_t s2)
-{
- tree val;
- val = vn_lookup_or_add_with_vuses (expr, vuses);
-
- /* 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);
-
- 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, VEC (tree, gc) *vuses)
-{
- bitmap_iterator bi;
- unsigned int bii;
- tree vh;
- bitmap_set_t exprset;
-
- if (REFERENCE_CLASS_P (t) || TREE_CODE (t) == CALL_EXPR || DECL_P (t))
- vh = vn_lookup_with_vuses (t, vuses);
- else
- vh = vn_lookup (t);
-
- 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.
-
- If CHECK_AVAIL is true, checks availability of each operand in
- BLOCKs AVAIL_OUT set. */
-
-static inline tree
-create_value_expr_from (tree expr, basic_block block, VEC (tree, gc) *vuses,
- bool check_avail)
-{
- 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 = NULL_TREE;
- tree 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, vuses, check_avail);
- op = tempop ? tempop : op;
- val = vn_lookup_or_add_with_vuses (op, vuses);
- set_expression_vuses (op, vuses);
- }
- else
- {
- val = vn_lookup_or_add (op);
- }
- if (TREE_CODE (op) != TREE_LIST)
- add_to_exp_gen (block, op);
-
- if (TREE_CODE (val) == VALUE_HANDLE)
- TREE_TYPE (val) = TREE_TYPE (TREE_OPERAND (vexpr, i));
-
- TREE_OPERAND (vexpr, i) = val;
-
- if (check_avail
- && TREE_CODE (val) == VALUE_HANDLE
- && !bitmap_set_contains_value (AVAIL_OUT (block), val))
- return NULL_TREE;
- }
- efi = find_existing_value_expr (vexpr, vuses);
- if (efi)
- return efi;
- get_or_alloc_expression_id (vexpr);
- return vexpr;
-}
-
-
-/* For each real store operation of the form
- *a = <value> that we see, create a corresponding fake store of the
- form storetmp_<version> = *a.
-
- This enables AVAIL computation to mark the results of stores as
- available. Without this, you'd need to do some computation to
- mark the result of stores as ANTIC and AVAIL at all the right
- points.
- To save memory, we keep the store
- statements pool allocated until we decide whether they are
- necessary or not. */
-
-static void
-insert_fake_stores (void)
-{
- basic_block block;
-
- FOR_ALL_BB (block)
- {
- block_stmt_iterator bsi;
- for (bsi = bsi_start (block); !bsi_end_p (bsi); bsi_next (&bsi))
- {
- tree stmt = bsi_stmt (bsi);
-
- /* We can't generate SSA names for stores that are complex
- or aggregate. We also want to ignore things whose
- virtual uses occur in abnormal phis. */
-
- if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT
- && (TREE_CODE (GIMPLE_STMT_OPERAND (stmt, 0)) == INDIRECT_REF
- || handled_component_p (GIMPLE_STMT_OPERAND (stmt, 0)))
- && !AGGREGATE_TYPE_P (TREE_TYPE (GIMPLE_STMT_OPERAND (stmt, 0))))
- {
- ssa_op_iter iter;
- def_operand_p defp;
- tree lhs = GIMPLE_STMT_OPERAND (stmt, 0);
- tree rhs = GIMPLE_STMT_OPERAND (stmt, 1);
- tree new_tree, new_lhs;
- bool notokay = false;
-
- FOR_EACH_SSA_DEF_OPERAND (defp, stmt, iter, SSA_OP_VIRTUAL_DEFS)
- {
- tree defvar = DEF_FROM_PTR (defp);
- if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (defvar))
- {
- notokay = true;
- break;
- }
- }
-
- if (notokay)
- continue;
-
- if (!storetemp || TREE_TYPE (rhs) != TREE_TYPE (storetemp))
- {
- storetemp = create_tmp_var (TREE_TYPE (rhs), "storetmp");
- if (TREE_CODE (TREE_TYPE (storetemp)) == VECTOR_TYPE
- || TREE_CODE (TREE_TYPE (storetemp)) == COMPLEX_TYPE)
- DECL_GIMPLE_REG_P (storetemp) = 1;
- get_var_ann (storetemp);
- }
-
- new_tree = build_gimple_modify_stmt (NULL_TREE, lhs);
- new_lhs = make_ssa_name (storetemp, new_tree);
- GIMPLE_STMT_OPERAND (new_tree, 0) = new_lhs;
-
- create_ssa_artificial_load_stmt (new_tree, stmt, false);
-
- NECESSARY (new_tree) = 0;
- VEC_safe_push (tree, heap, inserted_exprs, new_tree);
- VEC_safe_push (tree, heap, need_creation, new_tree);
- bsi_insert_after (&bsi, new_tree, BSI_NEW_STMT);
- }
- }