-} /* new_rd_Phi0 */
-
-
-/**
- * Internal constructor of a Phi node by a phi_merge operation.
- *
- * @param irg the graph on which the Phi will be constructed
- * @param block the block in which the Phi will be constructed
- * @param mode the mod eof the Phi node
- * @param in the input array of the phi node
- * @param ins number of elements in the input array
- * @param phi0 in non-NULL: the Phi0 node in the same block that represents
- * the value for which the new Phi is constructed
- */
-static inline ir_node *new_rd_Phi_in(ir_graph *irg, ir_node *block,
- ir_mode *mode, ir_node **in, int ins,
- ir_node *phi0)
-{
- int i;
- ir_node *res, *known;
-
- /* Allocate a new node on the obstack. The allocation copies the in
- array. */
- res = new_ir_node(NULL, irg, block, op_Phi, mode, ins, in);
- res->attr.phi.u.backedge = new_backedge_arr(irg->obst, ins);
-
- /* This loop checks whether the Phi has more than one predecessor.
- If so, it is a real Phi node and we break the loop. Else the
- Phi node merges the same definition on several paths and therefore
- is not needed.
- Note: We MUST consider Bad nodes, else we might get data flow cycles in dead loops! */
- known = res;
- for (i = ins - 1; i >= 0; --i) {
- assert(in[i]);
-
- in[i] = skip_Id(in[i]); /* increases the number of freed Phis. */
-
- /* Optimize self referencing Phis: We can't detect them yet properly, as
- they still refer to the Phi0 they will replace. So replace right now. */
- if (phi0 && in[i] == phi0)
- in[i] = res;
-
- if (in[i] == res || in[i] == known)
- continue;
-
- if (known == res)
- known = in[i];
- else
- break;
- }
-
- /* i < 0: there is at most one predecessor, we don't need a phi node. */
- if (i < 0) {
- if (res != known) {
- edges_node_deleted(res, current_ir_graph);
- obstack_free(current_ir_graph->obst, res);
- if (is_Phi(known)) {
- /* If pred is a phi node we want to optimize it: If loops are matured in a bad
- order, an enclosing Phi know may get superfluous. */
- res = optimize_in_place_2(known);
- if (res != known)
- exchange(known, res);
- }
- else
- res = known;
- } else {
- /* A undefined value, e.g., in unreachable code. */
- res = new_Bad();
- }
- } else {
- res = optimize_node(res); /* This is necessary to add the node to the hash table for cse. */
- IRN_VERIFY_IRG(res, irg);
- /* Memory Phis in endless loops must be kept alive.
- As we can't distinguish these easily we keep all of them alive. */
- if (is_Phi(res) && mode == mode_M)
- add_End_keepalive(get_irg_end(irg), res);
- }
-
- return res;
-} /* new_rd_Phi_in */