2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Cliff Click's Combined Analysis/Optimization
23 * @author Michael Beck
26 * Note that we use the terminology from Click's work here, which is different
27 * in some cases from Firm terminology. Especially, Click's type is a
28 * Firm tarval/entity, nevertheless we call it type here for "maximum compatibility".
36 #include "iroptimize.h"
44 #include "irgraph_t.h"
59 /* define this to check that all type translations are monotone */
60 #define VERIFY_MONOTONE
62 typedef struct node_t node_t;
63 typedef struct partition_t partition_t;
64 typedef struct opcode_key_t opcode_key_t;
65 typedef struct listmap_entry_t listmap_entry_t;
67 /** The type of the compute function. */
68 typedef void (*compute_func)(node_t *node);
74 ir_opcode code; /**< The Firm opcode. */
75 ir_mode *mode; /**< The mode of all nodes in the partition. */
77 long proj; /**< For Proj nodes, its proj number */
78 ir_entity *ent; /**< For Sel Nodes, its entity */
83 * An entry in the list_map.
85 struct listmap_entry_t {
86 void *id; /**< The id. */
87 node_t *list; /**< The associated list for this id. */
88 listmap_entry_t *next; /**< Link to the next entry in the map. */
91 /** We must map id's to lists. */
92 typedef struct listmap_t {
93 set *map; /**< Map id's to listmap_entry_t's */
94 listmap_entry_t *values; /**< List of all values in the map. */
98 * A lattice element. Because we handle constants and symbolic constants different, we
99 * have to use this union.
110 ir_node *node; /**< The IR-node itself. */
111 list_head node_list; /**< Double-linked list of entries. */
112 list_head cprop_list; /**< Double-linked partition.cprop list. */
113 partition_t *part; /**< points to the partition this node belongs to */
114 node_t *next; /**< Next node on local list (partition.touched, fallen). */
115 lattice_elem_t type; /**< The associated lattice element "type". */
116 int max_user_input; /**< Maximum input number of Def-Use edges. */
117 int next_edge; /**< Index of the next Def-Use edge to use. */
118 unsigned on_touched:1; /**< Set, if this node is on the partition.touched set. */
119 unsigned on_cprop:1; /**< Set, if this node is on the partition.cprop list. */
120 unsigned on_fallen:1; /**< Set, if this node is on the fallen list. */
124 * A partition containing congruent nodes.
127 list_head entries; /**< The head of partition node list. */
128 list_head cprop; /**< The head of partition.cprop list. */
129 partition_t *wl_next; /**< Next entry in the work list if any. */
130 partition_t *touched_next; /**< Points to the next partition in the touched set. */
131 partition_t *cprop_next; /**< Points to the next partition in the cprop list. */
132 node_t *touched; /**< The partition.touched set of this partition. */
133 unsigned n_nodes; /**< Number of entries in this partition. */
134 unsigned n_touched; /**< Number of entries in the partition.touched. */
135 int max_arity; /**< Maximum arity of all entries. */
136 int max_user_inputs; /**< Maximum number of user inputs of all entries. */
137 unsigned on_worklist:1; /**< Set, if this partition is in the work list. */
138 unsigned on_touched:1; /**< Set, if this partition is on the touched set. */
139 unsigned on_cprop:1; /**< Set, if this partition is on the cprop list. */
141 partition_t *dbg_next; /**< Link all partitions for debugging */
142 unsigned nr; /**< A unique number for (what-)mapping, >0. */
146 typedef struct environment_t {
147 struct obstack obst; /**< obstack to allocate data structures. */
148 partition_t *worklist; /**< The work list. */
149 partition_t *cprop; /**< The constant propagation list. */
150 partition_t *touched; /**< the touched set. */
151 partition_t *initial; /**< The initial partition. */
152 set *opcode2id_map; /**< The opcodeMode->id map. */
153 pmap *type2id_map; /**< The type->id map. */
154 int end_idx; /**< -1 for local and 0 for global congruences. */
155 int lambda_input; /**< Captured argument for lambda_partition(). */
157 partition_t *dbg_list; /**< List of all partitions. */
161 /** Type of the what function. */
162 typedef void *(*what_func)(const node_t *node, environment_t *env);
164 #define get_irn_node(irn) ((node_t *)get_irn_link(irn))
165 #define set_irn_node(irn, node) set_irn_link(irn, node)
167 /* we do NOT use tarval_unreachable here, instead we use Top for this purpose */
168 #undef tarval_unreachable
169 #define tarval_unreachable tarval_top
172 /** The debug module handle. */
173 DEBUG_ONLY(static firm_dbg_module_t *dbg;)
175 /** Next partition number. */
176 DEBUG_ONLY(static unsigned part_nr = 0);
179 static INLINE lattice_elem_t get_partition_type(const partition_t *X);
182 * Dump partition to output.
184 static void dump_partition(const char *msg, const partition_t *part) {
187 lattice_elem_t type = get_partition_type(part);
189 DB((dbg, LEVEL_2, "%s part%u (%u, %+F) {\n ", msg, part->nr, part->n_nodes, type));
190 list_for_each_entry(node_t, node, &part->entries, node_list) {
191 DB((dbg, LEVEL_2, "%s%+F", first ? "" : ", ", node->node));
194 DB((dbg, LEVEL_2, "\n}\n"));
198 * Dump all partitions.
200 static void dump_all_partitions(const environment_t *env) {
201 const partition_t *P;
203 DB((dbg, LEVEL_2, "All partitions\n===============\n"));
204 for (P = env->dbg_list; P != NULL; P = P->dbg_next)
205 dump_partition("", P);
209 #define dump_partition(msg, part)
210 #define dump_all_partitions(env)
213 #if defined(VERIFY_MONOTONE) && defined (DEBUG_libfirm)
215 * Verify that a type transition is monotone
217 static void verify_type(const lattice_elem_t old_type, const lattice_elem_t new_type) {
218 if (old_type.tv == new_type.tv) {
222 if (old_type.tv == tarval_top) {
223 /* from Top down-to is always allowed */
226 if (old_type.tv == tarval_reachable) {
227 panic("verify_type(): wrong translation from %+F to %+F", old_type, new_type);
229 if (new_type.tv == tarval_bottom || new_type.tv == tarval_reachable) {
233 panic("verify_type(): wrong translation from %+F to %+F", old_type, new_type);
236 #define verify_type(old_type, new_type)
240 * Compare two pointer values of a listmap.
242 static int listmap_cmp_ptr(const void *elt, const void *key, size_t size) {
243 const listmap_entry_t *e1 = elt;
244 const listmap_entry_t *e2 = key;
247 return e1->id != e2->id;
248 } /* listmap_cmp_ptr */
251 * Initializes a listmap.
253 * @param map the listmap
255 static void listmap_init(listmap_t *map) {
256 map->map = new_set(listmap_cmp_ptr, 16);
261 * Terminates a listmap.
263 * @param map the listmap
265 static void listmap_term(listmap_t *map) {
270 * Return the associated listmap entry for a given id.
272 * @param map the listmap
273 * @param id the id to search for
275 * @return the asociated listmap entry for the given id
277 static listmap_entry_t *listmap_find(listmap_t *map, void *id) {
278 listmap_entry_t key, *entry;
283 entry = set_insert(map->map, &key, sizeof(key), HASH_PTR(id));
285 if (entry->list == NULL) {
286 /* a new entry, put into the list */
287 entry->next = map->values;
294 * Calculate the hash value for an opcode map entry.
296 * @param entry an opcode map entry
298 * @return a hash value for the given opcode map entry
300 static unsigned opcode_hash(const opcode_key_t *entry) {
301 return (entry->mode - (ir_mode *)0) * 9 + entry->code + entry->u.proj * 3 + HASH_PTR(entry->u.ent);
305 * Compare two entries in the opcode map.
307 static int cmp_opcode(const void *elt, const void *key, size_t size) {
308 const opcode_key_t *o1 = elt;
309 const opcode_key_t *o2 = key;
312 return o1->code != o2->code || o1->mode != o2->mode ||
313 o1->u.proj != o2->u.proj || o1->u.ent != o2->u.ent;
317 * Compare two Def-Use edges for input position.
319 static int cmp_def_use_edge(const void *a, const void *b) {
320 const ir_def_use_edge *ea = a;
321 const ir_def_use_edge *eb = b;
323 /* no overrun, because range is [-1, MAXINT] */
324 return ea->pos - eb->pos;
325 } /* cmp_def_use_edge */
328 * We need the Def-Use edges sorted.
330 static void sort_irn_outs(node_t *node) {
331 ir_node *irn = node->node;
332 int n_outs = get_irn_n_outs(irn);
335 qsort(&irn->out[1], n_outs, sizeof(irn->out[0]), cmp_def_use_edge);
337 node->max_user_input = irn->out[n_outs].pos;
338 } /* sort_irn_outs */
341 * Return the type of a node.
343 * @param irn an IR-node
345 * @return the associated type of this node
347 static INLINE lattice_elem_t get_node_type(const ir_node *irn) {
348 return get_irn_node(irn)->type;
349 } /* get_node_type */
352 * Return the tarval of a node.
354 * @param irn an IR-node
356 * @return the associated type of this node
358 static INLINE tarval *get_node_tarval(const ir_node *irn) {
359 lattice_elem_t type = get_node_type(irn);
361 if (is_tarval(type.tv))
363 return tarval_bottom;
364 } /* get_node_type */
367 * Add a partition to the worklist.
369 static INLINE void add_to_worklist(partition_t *X, environment_t *env) {
370 assert(X->on_worklist == 0);
371 X->wl_next = env->worklist;
377 * Create a new empty partition.
379 * @param env the environment
381 * @return a newly allocated partition
383 static INLINE partition_t *new_partition(environment_t *env) {
384 partition_t *part = obstack_alloc(&env->obst, sizeof(*part));
386 INIT_LIST_HEAD(&part->entries);
387 INIT_LIST_HEAD(&part->cprop);
388 part->wl_next = NULL;
389 part->touched_next = NULL;
390 part->cprop_next = NULL;
391 part->touched = NULL;
395 part->max_user_inputs = 0;
396 part->on_worklist = 0;
397 part->on_touched = 0;
400 part->dbg_next = env->dbg_list;
401 env->dbg_list = part;
402 part->nr = part_nr++;
406 } /* new_partition */
409 * Get the first node from a partition.
411 static INLINE node_t *get_first_node(const partition_t *X) {
412 return list_entry(X->entries.next, node_t, node_list);
416 * Return the type of a partition (assuming partition is non-empty and
417 * all elements have the same type).
419 * @param X a partition
421 * @return the type of the first element of the partition
423 static INLINE lattice_elem_t get_partition_type(const partition_t *X) {
424 const node_t *first = get_first_node(X);
426 } /* get_partition_type */
429 * Creates a partition node for the given IR-node and place it
430 * into the given partition.
432 * @param irn an IR-node
433 * @param part a partition to place the node in
434 * @param env the environment
436 * @return the created node
438 static node_t *create_partition_node(ir_node *irn, partition_t *part, environment_t *env) {
439 /* create a partition node and place it in the partition */
440 node_t *node = obstack_alloc(&env->obst, sizeof(*node));
442 INIT_LIST_HEAD(&node->node_list);
443 INIT_LIST_HEAD(&node->cprop_list);
447 node->type.tv = tarval_top;
448 node->max_user_input = 0;
450 node->on_touched = 0;
453 set_irn_node(irn, node);
455 list_add_tail(&node->node_list, &part->entries);
459 } /* create_partition_node */
462 * Pre-Walker, init all Block-Phi lists.
464 static void init_block_phis(ir_node *irn, void *env) {
468 set_Block_phis(irn, NULL);
473 * Post-Walker, initialize all Nodes' type to U or top and place
474 * all nodes into the TOP partition.
476 static void create_initial_partitions(ir_node *irn, void *ctx) {
477 environment_t *env = ctx;
478 partition_t *part = env->initial;
482 node = create_partition_node(irn, part, env);
484 arity = get_irn_arity(irn);
485 if (arity > part->max_arity)
486 part->max_arity = arity;
487 if (node->max_user_input > part->max_user_inputs)
488 part->max_user_inputs = node->max_user_input;
491 add_Block_phi(get_nodes_block(irn), irn);
493 } /* create_initial_partitions */
496 * Add a partition to the touched set if not already there.
498 * @param part the partition
499 * @param env the environment
501 static INLINE void add_to_touched(partition_t *part, environment_t *env) {
502 if (part->on_touched == 0) {
503 part->touched_next = env->touched;
505 part->on_touched = 1;
507 } /* add_to_touched */
510 * Add a node to the entry.partition.touched set if not already there.
514 static INLINE void add_to_partition_touched(node_t *y) {
515 if (y->on_touched == 0) {
516 partition_t *part = y->part;
518 y->next = part->touched;
523 } /* add_to_partition_touched */
526 * Update the worklist: If Z is on worklist then add Z' to worklist.
527 * Else add the smaller of Z and Z' to worklist.
529 * @param Z the Z partition
530 * @param Z_prime the Z' partition, a previous part of Z
531 * @param env the environment
533 static void update_worklist(partition_t *Z, partition_t *Z_prime, environment_t *env) {
534 if (Z->on_worklist || Z_prime->n_nodes < Z->n_nodes) {
535 add_to_worklist(Z_prime, env);
537 add_to_worklist(Z, env);
539 } /* update_worklist */
542 * Split a partition by a local list.
544 * @param Z the Z partition to split
545 * @param g a (non-empty) node list
546 * @param env the environment
548 * @return a new partition containing the nodes of g
550 static partition_t *split(partition_t *Z, node_t *g, environment_t *env) {
551 partition_t *Z_prime;
554 int max_input, max_arity, arity;
556 dump_partition("Splitting ", Z);
560 /* Remove g from Z. */
561 for (node = g; node != NULL; node = node->next) {
562 list_del(&node->node_list);
565 assert(n < Z->n_nodes);
568 /* Move g to a new partition, Z
\92. */
569 Z_prime = new_partition(env);
570 max_arity = max_input = 0;
571 for (node = g; node != NULL; node = node->next) {
572 list_add(&node->node_list, &Z_prime->entries);
573 node->part = Z_prime;
574 arity = get_irn_arity(node->node);
575 if (arity > max_arity)
577 if (node->max_user_input > max_input)
578 max_input = node->max_user_input;
580 Z_prime->max_arity = max_arity;
581 Z_prime->max_user_inputs = max_input;
582 Z_prime->n_nodes = n;
584 update_worklist(Z, Z_prime, env);
586 dump_partition("Now ", Z);
587 dump_partition("Created new ", Z_prime);
592 * Returns non-zero if the i'th input of a Phi node is live.
594 * @param phi a Phi-node
595 * @param i an input number
597 * @return non-zero if the i'th input of the given Phi node is live
599 static int is_live_input(ir_node *phi, int i) {
601 ir_node *block = get_nodes_block(phi);
602 ir_node *pred = get_Block_cfgpred(block, i);
603 lattice_elem_t type = get_node_type(pred);
605 return type.tv != tarval_unreachable;
607 /* else it's the control input, always live */
609 } /* is_live_input */
612 * Return non-zero if a type is a constant.
614 static int is_constant_type(lattice_elem_t type) {
615 if (type.tv != tarval_bottom && type.tv != tarval_top)
618 } /* is_constant_type */
621 * Place a node on the cprop list.
624 * @param env the environment
626 static void add_node_to_cprop(node_t *y, environment_t *env) {
627 /* Add y to y.partition.cprop. */
628 if (y->on_cprop == 0) {
629 partition_t *Y = y->part;
631 list_add_tail(&y->cprop_list, &Y->cprop);
634 DB((dbg, LEVEL_3, "Add %+F to part%u.cprop\n", y->node, Y->nr));
636 /* place its partition on the cprop list */
637 if (Y->on_cprop == 0) {
638 Y->cprop_next = env->cprop;
643 if (get_irn_mode(y->node) == mode_T) {
644 /* mode_T nodes always produce tarval_bottom, so we must explicitly
645 add it's Proj's to get constant evaluation to work */
648 for (i = get_irn_n_outs(y->node) - 1; i >= 0; --i) {
649 node_t *proj = get_irn_node(get_irn_out(y->node, i));
651 add_node_to_cprop(proj, env);
655 if (is_Block(y->node)) {
656 /* Due to the way we handle Phi's, we must place all Phis of a block on the list
657 * if someone placed the block. The Block is only placed if the reachability
658 * changes, and this must be re-evaluated in compute_Phi(). */
660 for (phi = get_Block_phis(y->node); phi != NULL; phi = get_Phi_next(phi)) {
661 node_t *p = get_irn_node(phi);
662 add_node_to_cprop(p, env);
665 } /* add_node_to_cprop */
668 * Check whether a type is neither Top or a constant.
669 * Note: U is handled like Top here, R is a constant.
671 * @param type the type to check
673 static int type_is_neither_top_nor_const(const lattice_elem_t type) {
674 if (is_tarval(type.tv)) {
675 if (type.tv == tarval_top)
677 if (tarval_is_constant(type.tv))
687 * Split the partitions if caused by the first entry on the worklist.
689 * @param env the environment
691 static void cause_splits(environment_t *env) {
692 partition_t *X, *Y, *Z;
698 /* remove the first partition from the worklist */
700 env->worklist = X->wl_next;
703 dump_partition("Cause_split: ", X);
704 end_idx = env->end_idx;
705 for (i = -1; i <= X->max_user_inputs; ++i) {
706 /* empty the touched set: already done, just clear the list */
709 list_for_each_entry(node_t, x, &X->entries, node_list) {
715 num_edges = get_irn_n_outs(x->node);
717 while (x->next_edge <= num_edges) {
718 ir_def_use_edge *edge = &x->node->out[x->next_edge];
720 /* check if we have necessary edges */
728 /* ignore the "control input" for non-pinned nodes
729 if we are running in GCSE mode */
730 if (i < end_idx && get_irn_pinned(succ) != op_pin_state_pinned)
733 y = get_irn_node(succ);
734 if (is_constant_type(y->type)) {
735 code = get_irn_opcode(succ);
736 if (code == iro_Sub || code == iro_Cmp)
737 add_node_to_cprop(y, env);
740 /* Partitions of constants should not be split simply because their Nodes have unequal
741 functions or incongruent inputs. */
742 if (type_is_neither_top_nor_const(y->type) &&
743 (! is_Phi(y->node) || is_live_input(y->node, i))) {
745 add_to_touched(Y, env);
746 add_to_partition_touched(y);
751 for (Z = env->touched; Z != NULL; Z = Z->touched_next) {
752 /* remove it from the touched set */
755 if (Z->n_nodes != Z->n_touched) {
756 DB((dbg, LEVEL_2, "Split part%d by touched\n", Z->nr));
757 split(Z, Z->touched, env);
759 /* Empty local Z.touched. */
760 for (e = Z->touched; e != NULL; e = e->next) {
770 * Implements split_by_what(): Split a partition by characteristics given
771 * by the what function.
773 * @param X the partition to split
774 * @param What a function returning an Id for every node of the partition X
775 * @param P an flexible array to store the result partitions or NULL
776 * @param env the environment
778 * @return if P != NULL P will be filled with the resulting partitions and returned
780 static partition_t **split_by_what(partition_t *X, what_func What,
781 partition_t **P, environment_t *env) {
784 listmap_entry_t *iter;
787 /* Let map be an empty mapping from the range of What to (local) list of Nodes. */
789 list_for_each_entry(node_t, x, &X->entries, node_list) {
790 void *id = What(x, env);
791 listmap_entry_t *entry;
794 /* input not allowed, ignore */
797 /* Add x to map[What(x)]. */
798 entry = listmap_find(&map, id);
799 x->next = entry->list;
802 /* Let P be a set of Partitions. */
804 /* for all sets S except one in the range of map do */
805 for (iter = map.values; iter != NULL; iter = iter->next) {
806 if (iter->next == NULL) {
807 /* this is the last entry, ignore */
812 /* Add SPLIT( X, S ) to P. */
813 DB((dbg, LEVEL_2, "Split part%d by what\n", X->nr));
814 R = split(X, S, env);
815 ARR_APP1(partition_t *, P, R);
818 ARR_APP1(partition_t *, P, X);
822 } /* split_by_what */
824 /** lambda n.(n.type) */
825 static void *lambda_type(const node_t *node, environment_t *env) {
827 return node->type.tv;
830 /** lambda n.(n.opcode) */
831 static void *lambda_opcode(const node_t *node, environment_t *env) {
832 opcode_key_t key, *entry;
833 ir_node *irn = node->node;
835 key.code = get_irn_opcode(irn);
836 key.mode = get_irn_mode(irn);
840 switch (get_irn_opcode(irn)) {
842 key.u.proj = get_Proj_proj(irn);
845 key.u.ent = get_Sel_entity(irn);
851 entry = set_insert(env->opcode2id_map, &key, sizeof(key), opcode_hash(&key));
853 } /* lambda_opcode */
855 /** lambda n.(n[i].partition) */
856 static void *lambda_partition(const node_t *node, environment_t *env) {
857 ir_node *skipped = skip_Proj(node->node);
860 int i = env->lambda_input;
862 if (i >= get_irn_arity(node->node)) {
863 /* we are outside the allowed range */
867 /* ignore the "control input" for non-pinned nodes
868 if we are running in GCSE mode */
869 if (i < env->end_idx && get_irn_pinned(skipped) != op_pin_state_pinned)
872 pred = i == -1 ? get_irn_n(skipped, i) : get_irn_n(node->node, i);
873 p = get_irn_node(pred);
876 } /* lambda_partition */
879 * Checks whether a type is a constant.
881 static int is_type_constant(lattice_elem_t type) {
882 if (is_tarval(type.tv))
883 return tarval_is_constant(type.tv);
884 /* else it is a symconst */
889 * Implements split_by().
891 * @param X the partition to split
892 * @param env the environment
894 static void split_by(partition_t *X, environment_t *env) {
895 partition_t **P = NEW_ARR_F(partition_t *, 0);
898 DB((dbg, LEVEL_2, "WHAT = lambda n.(n.type) on part%d\n", X->nr));
899 P = split_by_what(X, lambda_type, P, env);
900 for (i = ARR_LEN(P) - 1; i >= 0; --i) {
901 partition_t *Y = P[i];
903 if (Y->n_nodes > 1) {
904 lattice_elem_t type = get_partition_type(Y);
906 /* we do not want split the TOP or constant partitions */
907 if (type.tv != tarval_top && !is_type_constant(type)) {
908 partition_t **Q = NEW_ARR_F(partition_t *, 0);
910 DB((dbg, LEVEL_2, "WHAT = lambda n.(n.opcode) on part%d\n", Y->nr));
911 Q = split_by_what(Y, lambda_opcode, Q, env);
913 for (j = ARR_LEN(Q) - 1; j >= 0; --j) {
914 partition_t *Z = Q[j];
915 int max_arity = Z->max_arity;
916 partition_t **R = NEW_ARR_F(partition_t *, 1);
917 partition_t **S = NULL;
920 * BEWARE: during splitting by input 2 for instance we might
921 * create new partitions which are different by input 1, so collect
922 * them and split further.
925 for (input = max_arity - 1; input >= -1; --input) {
926 S = NEW_ARR_F(partition_t *, 0);
927 for (k = 0; k < ARR_LEN(R); ++k) {
928 partition_t *Z_prime = R[k];
929 if (Z_prime->n_nodes > 1) {
930 env->lambda_input = input;
931 DB((dbg, LEVEL_2, "WHAT = lambda n.(n[%d].partition) on part%d\n", input, Z_prime->nr));
932 S = split_by_what(Z_prime, lambda_partition, S, env);
948 * (Re-)compute the type for a given node.
950 * @param node the node
952 static void default_compute(node_t *node) {
954 ir_node *irn = node->node;
955 node_t *block = get_irn_node(get_nodes_block(irn));
957 if (block->type.tv == tarval_unreachable) {
958 node->type.tv = tarval_top;
962 /* if any of the data inputs have type top, the result is type top */
963 for (i = get_irn_arity(irn) - 1; i >= 0; --i) {
964 ir_node *pred = get_irn_n(irn, i);
965 node_t *p = get_irn_node(pred);
967 if (p->type.tv == tarval_top) {
968 node->type.tv = tarval_top;
973 if (get_irn_mode(node->node) == mode_X)
974 node->type.tv = tarval_reachable;
976 node->type.tv = computed_value(irn);
977 } /* default_compute */
980 * (Re-)compute the type for a Block node.
982 * @param node the node
984 static void compute_Block(node_t *node) {
986 ir_node *block = node->node;
988 for (i = get_Block_n_cfgpreds(block) - 1; i >= 0; --i) {
989 node_t *pred = get_irn_node(get_Block_cfgpred(block, i));
991 if (pred->type.tv == tarval_reachable) {
992 /* A block is reachable, if at least of predecessor is reachable. */
993 node->type.tv = tarval_reachable;
997 node->type.tv = tarval_top;
998 } /* compute_Block */
1001 * (Re-)compute the type for a Bad node.
1003 * @param node the node
1005 static void compute_Bad(node_t *node) {
1006 /* Bad nodes ALWAYS compute Top */
1007 node->type.tv = tarval_top;
1011 * (Re-)compute the type for an Unknown node.
1013 * @param node the node
1015 static void compute_Unknown(node_t *node) {
1016 /* While Unknown nodes compute Top, but this is dangerous:
1017 * a if (unknown) would lead to BOTH control flows unreachable.
1018 * While this is correct in the given semantics, it would destroy the Firm
1020 * For now, we compute bottom here.
1022 node->type.tv = tarval_bottom;
1023 } /* compute_Unknown */
1026 * (Re-)compute the type for a Jmp node.
1028 * @param node the node
1030 static void compute_Jmp(node_t *node) {
1031 node_t *block = get_irn_node(get_nodes_block(node->node));
1033 node->type = block->type;
1037 * (Re-)compute the type for the End node.
1039 * @param node the node
1041 static void compute_End(node_t *node) {
1042 /* the End node is NOT dead of course */
1043 node->type.tv = tarval_reachable;
1047 * (Re-)compute the type for a SymConst node.
1049 * @param node the node
1051 static void compute_SymConst(node_t *node) {
1052 ir_node *irn = node->node;
1053 node_t *block = get_irn_node(get_nodes_block(irn));
1055 if (block->type.tv == tarval_unreachable) {
1056 node->type.tv = tarval_top;
1059 switch (get_SymConst_kind(irn)) {
1060 case symconst_addr_ent:
1061 /* case symconst_addr_name: cannot handle this yet */
1062 node->type.sym = get_SymConst_symbol(irn);
1065 node->type.tv = computed_value(irn);
1067 } /* compute_SymConst */
1070 * (Re-)compute the type for a Phi node.
1072 * @param node the node
1074 static void compute_Phi(node_t *node) {
1076 ir_node *phi = node->node;
1077 lattice_elem_t type;
1079 /* if a Phi is in a unreachable block, its type is TOP */
1080 node_t *block = get_irn_node(get_nodes_block(phi));
1082 if (block->type.tv == tarval_unreachable) {
1083 node->type.tv = tarval_top;
1087 /* Phi implements the Meet operation */
1088 type.tv = tarval_top;
1089 for (i = get_Phi_n_preds(phi) - 1; i >= 0; --i) {
1090 node_t *pred = get_irn_node(get_Phi_pred(phi, i));
1091 node_t *pred_X = get_irn_node(get_Block_cfgpred(block->node, i));
1093 if (pred_X->type.tv == tarval_unreachable || pred->type.tv == tarval_top) {
1094 /* ignore TOP inputs: We must check here for unreachable blocks,
1095 because Firm constants live in the Start Block are NEVER Top.
1096 Else, a Phi (1,2) will produce Bottom, even if the 2 for instance
1097 comes from a unreachable input. */
1100 if (pred->type.tv == tarval_bottom) {
1101 node->type.tv = tarval_bottom;
1103 } else if (type.tv == tarval_top) {
1104 /* first constant found */
1106 } else if (type.tv != pred->type.tv) {
1107 /* different constants or tarval_bottom */
1108 node->type.tv = tarval_bottom;
1111 /* else nothing, constants are the same */
1117 * (Re-)compute the type for an Add. Special case: one nodes is a Zero Const.
1119 * @param node the node
1121 static void compute_Add(node_t *node) {
1122 ir_node *sub = node->node;
1123 node_t *l = get_irn_node(get_Add_left(sub));
1124 node_t *r = get_irn_node(get_Add_right(sub));
1125 lattice_elem_t a = l->type;
1126 lattice_elem_t b = r->type;
1127 node_t *block = get_irn_node(get_nodes_block(sub));
1130 if (block->type.tv == tarval_unreachable) {
1131 node->type.tv = tarval_top;
1135 if (a.tv == tarval_top || b.tv == tarval_top) {
1136 node->type.tv = tarval_top;
1137 } else if (a.tv == tarval_bottom || b.tv == tarval_bottom) {
1138 node->type.tv = tarval_bottom;
1140 /* x + 0 = 0 + x = x, but beware of floating point +0 + -0, so we
1141 must call tarval_add() first to handle this case! */
1142 if (is_tarval(a.tv)) {
1143 if (is_tarval(b.tv)) {
1144 node->type.tv = tarval_add(a.tv, b.tv);
1147 mode = get_tarval_mode(a.tv);
1148 if (a.tv == get_mode_null(mode)) {
1152 } else if (is_tarval(b.tv)) {
1153 mode = get_tarval_mode(b.tv);
1154 if (b.tv == get_mode_null(mode)) {
1159 node->type.tv = tarval_bottom;
1164 * Returns true if a type is a constant.
1166 static int is_con(const lattice_elem_t type) {
1167 return is_entity(type.sym.entity_p) || tarval_is_constant(type.tv);
1171 * (Re-)compute the type for a Sub. Special case: both nodes are congruent.
1173 * @param node the node
1175 static void compute_Sub(node_t *node) {
1176 ir_node *sub = node->node;
1177 node_t *l = get_irn_node(get_Sub_left(sub));
1178 node_t *r = get_irn_node(get_Sub_right(sub));
1179 lattice_elem_t a = l->type;
1180 lattice_elem_t b = r->type;
1181 node_t *block = get_irn_node(get_nodes_block(sub));
1183 if (block->type.tv == tarval_unreachable) {
1184 node->type.tv = tarval_top;
1187 if (a.tv == tarval_top || b.tv == tarval_top) {
1188 node->type.tv = tarval_top;
1189 } else if (is_con(a) && is_con(b)) {
1190 if (is_tarval(a.tv) && is_tarval(b.tv)) {
1191 node->type.tv = tarval_sub(a.tv, b.tv);
1192 } else if (is_tarval(a.tv) && tarval_is_null(a.tv)) {
1194 } else if (is_tarval(b.tv) && tarval_is_null(b.tv)) {
1197 node->type.tv = tarval_bottom;
1199 } else if (r->part == l->part &&
1200 (!mode_is_float(get_irn_mode(l->node)))) {
1201 if (node->type.tv == tarval_top) {
1203 * BEWARE: a - a is NOT always 0 for floating Point values, as
1204 * NaN op NaN = NaN, so we must check this here.
1206 ir_mode *mode = get_irn_mode(sub);
1207 node->type.tv = get_mode_null(mode);
1209 node->type.tv = tarval_bottom;
1212 node->type.tv = tarval_bottom;
1217 * (Re-)compute the type for Cmp.
1219 * @param node the node
1221 static void compute_Cmp(node_t *node) {
1222 ir_node *cmp = node->node;
1223 node_t *l = get_irn_node(get_Cmp_left(cmp));
1224 node_t *r = get_irn_node(get_Cmp_right(cmp));
1225 lattice_elem_t a = l->type;
1226 lattice_elem_t b = r->type;
1228 if (a.tv == tarval_top || b.tv == tarval_top) {
1229 node->type.tv = tarval_top;
1230 } else if (is_con(a) && is_con(b)) {
1231 /* both nodes are constants, we can propbably do something */
1232 node->type.tv = tarval_b_true;
1233 } else if (r->part == l->part) {
1234 /* both nodes congruent, we can probably do something */
1235 node->type.tv = tarval_b_true;
1237 node->type.tv = tarval_bottom;
1239 } /* compute_Proj_Cmp */
1242 * (Re-)compute the type for a Proj(Cmp).
1244 * @param node the node
1245 * @param cond the predecessor Cmp node
1247 static void compute_Proj_Cmp(node_t *node, ir_node *cmp) {
1248 ir_node *proj = node->node;
1249 node_t *l = get_irn_node(get_Cmp_left(cmp));
1250 node_t *r = get_irn_node(get_Cmp_right(cmp));
1251 lattice_elem_t a = l->type;
1252 lattice_elem_t b = r->type;
1253 pn_Cmp pnc = get_Proj_proj(proj);
1255 if (a.tv == tarval_top || b.tv == tarval_top) {
1256 node->type.tv = tarval_top;
1257 } else if (is_con(a) && is_con(b)) {
1258 default_compute(node);
1259 } else if (r->part == l->part &&
1260 (!mode_is_float(get_irn_mode(l->node)) || pnc == pn_Cmp_Lt || pnc == pn_Cmp_Gt)) {
1261 if (node->type.tv == tarval_top) {
1263 * BEWARE: a == a is NOT always True for floating Point values, as
1264 * NaN != NaN is defined, so we must check this here.
1266 node->type.tv = new_tarval_from_long(pnc & pn_Cmp_Eq, mode_b);
1268 node->type.tv = tarval_bottom;
1271 node->type.tv = tarval_bottom;
1273 } /* compute_Proj_Cmp */
1276 * (Re-)compute the type for a Proj(Cond).
1278 * @param node the node
1279 * @param cond the predecessor Cond node
1281 static void compute_Proj_Cond(node_t *node, ir_node *cond) {
1282 ir_node *proj = node->node;
1283 long pnc = get_Proj_proj(proj);
1284 ir_node *sel = get_Cond_selector(cond);
1285 node_t *selector = get_irn_node(sel);
1287 if (get_irn_mode(sel) == mode_b) {
1289 if (pnc == pn_Cond_true) {
1290 if (selector->type.tv == tarval_b_false) {
1291 node->type.tv = tarval_unreachable;
1292 } else if (selector->type.tv == tarval_b_true) {
1293 node->type.tv = tarval_reachable;
1294 } else if (selector->type.tv == tarval_bottom) {
1295 node->type.tv = tarval_reachable;
1297 assert(selector->type.tv == tarval_top);
1298 node->type.tv = tarval_unreachable;
1301 assert(pnc == pn_Cond_false);
1303 if (selector->type.tv == tarval_b_false) {
1304 node->type.tv = tarval_reachable;
1305 } else if (selector->type.tv == tarval_b_true) {
1306 node->type.tv = tarval_unreachable;
1307 } else if (selector->type.tv == tarval_bottom) {
1308 node->type.tv = tarval_reachable;
1310 assert(selector->type.tv == tarval_top);
1311 node->type.tv = tarval_unreachable;
1316 if (selector->type.tv == tarval_bottom) {
1317 node->type.tv = tarval_reachable;
1318 } else if (selector->type.tv == tarval_top) {
1319 node->type.tv = tarval_unreachable;
1321 long value = get_tarval_long(selector->type.tv);
1322 if (pnc == get_Cond_defaultProj(cond)) {
1323 /* default switch, have to check ALL other cases */
1326 for (i = get_irn_n_outs(cond) - 1; i >= 0; --i) {
1327 ir_node *succ = get_irn_out(cond, i);
1331 if (value == get_Proj_proj(succ)) {
1332 /* we found a match, will NOT take the default case */
1333 node->type.tv = tarval_unreachable;
1337 /* all cases checked, no match, will take default case */
1338 node->type.tv = tarval_reachable;
1341 node->type.tv = value == pnc ? tarval_reachable : tarval_unreachable;
1345 } /* compute_Proj_Cond */
1348 * (Re-)compute the type for a Proj-Nodes.
1350 * @param node the node
1352 static void compute_Proj(node_t *node) {
1353 ir_node *proj = node->node;
1354 ir_mode *mode = get_irn_mode(proj);
1355 node_t *block = get_irn_node(get_nodes_block(skip_Proj(proj)));
1356 ir_node *pred = get_Proj_pred(proj);
1358 if (get_Proj_proj(proj) == pn_Start_X_initial_exec && is_Start(pred)) {
1359 /* The initial_exec node is ALWAYS reachable. */
1360 node->type.tv = tarval_reachable;
1364 if (block->type.tv == tarval_unreachable) {
1365 /* a Proj in a unreachable Block stay Top */
1366 node->type.tv = tarval_top;
1369 if (get_irn_node(pred)->type.tv == tarval_top) {
1370 /* if the predecessor is Top, its Proj follow */
1371 node->type.tv = tarval_top;
1375 if (mode == mode_M) {
1376 /* mode M is always bottom */
1377 node->type.tv = tarval_bottom;
1380 if (mode != mode_X) {
1382 compute_Proj_Cmp(node, pred);
1384 default_compute(node);
1387 /* handle mode_X nodes */
1389 switch (get_irn_opcode(pred)) {
1391 /* the Proj_X from the Start is always reachable.
1392 However this is already handled at the top. */
1393 node->type.tv = tarval_reachable;
1396 compute_Proj_Cond(node, pred);
1399 default_compute(node);
1401 } /* compute_Proj */
1404 * (Re-)compute the type for a Confirm-Nodes.
1406 * @param node the node
1408 static void compute_Confirm(node_t *node) {
1409 ir_node *confirm = node->node;
1410 node_t *pred = get_irn_node(get_Confirm_value(confirm));
1412 if (get_Confirm_cmp(confirm) == pn_Cmp_Eq) {
1413 node_t *bound = get_irn_node(get_Confirm_bound(confirm));
1415 if (is_con(bound->type)) {
1416 /* is equal to a constant */
1417 node->type = bound->type;
1421 /* a Confirm is a copy OR a Const */
1422 node->type = pred->type;
1423 } /* compute_Confirm */
1426 * (Re-)compute the type for a given node.
1428 * @param node the node
1430 static void compute(node_t *node) {
1431 compute_func func = (compute_func)node->node->op->ops.generic;
1438 * Propagate constant evaluation.
1440 * @param env the environment
1442 static void propagate(environment_t *env) {
1445 lattice_elem_t old_type;
1450 while (env->cprop != NULL) {
1451 /* remove the first partition X from cprop */
1454 env->cprop = X->cprop_next;
1456 DB((dbg, LEVEL_2, "Propagate type on part%d\n", X->nr));
1459 while (! list_empty(&X->cprop)) {
1460 /* remove the first Node x from X.cprop */
1461 x = list_entry(X->cprop.next, node_t, cprop_list);
1462 list_del(&x->cprop_list);
1465 /* compute a new type for x */
1467 DB((dbg, LEVEL_3, "computing type of %+F\n", x->node));
1469 if (x->type.tv != old_type.tv) {
1470 verify_type(old_type, x->type);
1471 DB((dbg, LEVEL_2, "node %+F has changed type from %+F to %+F\n", x->node, old_type, x->type));
1473 if (x->on_fallen == 0) {
1474 /* Add x to fallen. Nodes might fall from T -> const -> _|_, so check that they are
1475 not already on the list. */
1480 DB((dbg, LEVEL_2, "Add node %+F to fallen\n", x->node));
1482 for (i = get_irn_n_outs(x->node) - 1; i >= 0; --i) {
1483 ir_node *succ = get_irn_out(x->node, i);
1484 node_t *y = get_irn_node(succ);
1486 /* Add y to y.partition.cprop. */
1487 add_node_to_cprop(y, env);
1492 if (n_fallen > 0 && n_fallen != X->n_nodes) {
1493 DB((dbg, LEVEL_2, "Splitting part%d by fallen\n", X->nr));
1494 Y = split(X, fallen, env);
1498 /* remove the nodes from the fallen list */
1499 for (x = fallen; x != NULL; x = x->next)
1508 * Get the leader for a given node from its congruence class.
1510 * @param irn the node
1512 static ir_node *get_leader(node_t *node) {
1513 partition_t *part = node->part;
1515 if (part->n_nodes > 1) {
1516 DB((dbg, LEVEL_2, "Found congruence class for %+F\n", node->node));
1518 return get_first_node(part)->node;
1524 * Return non-zero if the control flow predecessor node pred
1525 * is the only reachable control flow exit of its block.
1527 * @param pred the control flow exit
1529 static int can_exchange(ir_node *pred) {
1532 else if (is_Jmp(pred))
1534 else if (get_irn_mode(pred) == mode_T) {
1537 /* if the predecessor block has more than one
1538 reachable outputs we cannot remove the block */
1540 for (i = get_irn_n_outs(pred) - 1; i >= 0; --i) {
1541 ir_node *proj = get_irn_out(pred, i);
1544 /* skip non-control flow Proj's */
1545 if (get_irn_mode(proj) != mode_X)
1548 node = get_irn_node(proj);
1549 if (node->type.tv == tarval_reachable) {
1560 * Block Post-Walker, apply the analysis results on control flow by
1561 * shortening Phi's and Block inputs.
1563 static void apply_cf(ir_node *block, void *ctx) {
1564 node_t *node = get_irn_node(block);
1566 ir_node **ins, **in_X;
1567 ir_node *phi, *next;
1570 if (block == get_irg_end_block(current_ir_graph) ||
1571 block == get_irg_start_block(current_ir_graph)) {
1572 /* the EndBlock is always reachable even if the analysis
1573 finds out the opposite :-) */
1576 if (node->type.tv == tarval_unreachable) {
1577 /* mark dead blocks */
1578 set_Block_dead(block);
1582 n = get_Block_n_cfgpreds(block);
1585 /* only one predecessor combine */
1586 ir_node *pred = skip_Proj(get_Block_cfgpred(block, 0));
1588 if (can_exchange(pred))
1589 exchange(block, get_nodes_block(pred));
1593 NEW_ARR_A(ir_node *, in_X, n);
1595 for (i = 0; i < n; ++i) {
1596 ir_node *pred = get_Block_cfgpred(block, i);
1597 node_t *node = get_irn_node(pred);
1599 if (node->type.tv == tarval_reachable) {
1606 NEW_ARR_A(ir_node *, ins, n);
1607 for (phi = get_Block_phis(block); phi != NULL; phi = next) {
1608 node_t *node = get_irn_node(phi);
1610 next = get_Phi_next(phi);
1611 if (is_tarval(node->type.tv) && tarval_is_constant(node->type.tv)) {
1612 /* this Phi is replaced by a constant */
1613 tarval *tv = node->type.tv;
1614 ir_node *c = new_r_Const(current_ir_graph, block, get_tarval_mode(tv), tv);
1616 set_irn_node(c, node);
1618 DB((dbg, LEVEL_1, "%+F is replaced by %+F\n", phi, c));
1622 for (i = 0; i < n; ++i) {
1623 node_t *pred = get_irn_node(get_Block_cfgpred(block, i));
1625 if (pred->type.tv == tarval_reachable) {
1626 ins[j++] = get_Phi_pred(phi, i);
1630 /* this Phi is replaced by a single predecessor */
1631 ir_node *s = ins[0];
1634 DB((dbg, LEVEL_1, "%+F is replaced by %+F\n", phi, s));
1637 set_irn_in(phi, j, ins);
1643 /* this Block has only one live predecessor */
1644 ir_node *pred = skip_Proj(in_X[0]);
1646 if (can_exchange(pred))
1647 exchange(block, get_nodes_block(pred));
1649 set_irn_in(block, j, in_X);
1654 * Post-Walker, apply the analysis results;
1656 static void apply_result(ir_node *irn, void *ctx) {
1657 node_t *node = get_irn_node(irn);
1660 if (is_Block(irn) || is_End(irn)) {
1661 /* blocks already handled, do not touch the End node */
1663 node_t *block = get_irn_node(get_nodes_block(irn));
1665 if (block->type.tv == tarval_unreachable) {
1666 if (! is_Bad(irn)) {
1667 ir_node *bad = get_irg_bad(current_ir_graph);
1669 /* here, bad might already have a node, but this can be safely ignored
1670 as long as bad has at least ONE valid node */
1671 set_irn_node(bad, node);
1673 DB((dbg, LEVEL_1, "%+F is unreachable\n", irn));
1677 else if (get_irn_mode(irn) == mode_X) {
1678 if (node->type.tv == tarval_unreachable) {
1679 ir_node *bad = get_irg_bad(current_ir_graph);
1681 /* see comment above */
1682 set_irn_node(bad, node);
1684 DB((dbg, LEVEL_1, "%+F is unreachable\n", irn));
1687 else if (is_Proj(irn)) {
1689 ir_node *cond = get_Proj_pred(irn);
1691 if (is_Cond(cond)) {
1692 node_t *sel = get_irn_node(get_Cond_selector(cond));
1694 if (is_tarval(sel->type.tv) && tarval_is_constant(sel->type.tv)) {
1695 /* Cond selector is a constant, make a Jmp */
1696 ir_node *jmp = new_r_Jmp(current_ir_graph, block->node);
1697 set_irn_node(jmp, node);
1699 DB((dbg, LEVEL_1, "%+F is replaced by %+F\n", irn, jmp));
1705 /* normal data node */
1706 if (is_tarval(node->type.tv) && tarval_is_constant(node->type.tv)) {
1707 tarval *tv = node->type.tv;
1709 if (! is_Const(irn)) {
1710 /* can be replaced by a constant */
1711 ir_node *c = new_r_Const(current_ir_graph, block->node, get_tarval_mode(tv), tv);
1712 set_irn_node(c, node);
1714 DB((dbg, LEVEL_1, "%+F is replaced by %+F\n", irn, c));
1717 } else if (is_entity(node->type.sym.entity_p)) {
1718 if (! is_SymConst(irn)) {
1719 /* can be replaced by a Symconst */
1720 ir_node *symc = new_r_SymConst(current_ir_graph, block->node, get_irn_mode(irn), node->type.sym, symconst_addr_ent);
1721 set_irn_node(symc, node);
1724 DB((dbg, LEVEL_1, "%+F is replaced by %+F\n", irn, symc));
1725 exchange(irn, symc);
1728 ir_node *leader = get_leader(node);
1730 if (leader != irn) {
1731 DB((dbg, LEVEL_1, "%+F from part%d is replaced by %+F\n", irn, node->part->nr, leader));
1732 exchange(irn, leader);
1737 } /* apply_result */
1739 #define SET(code) op_##code->ops.generic = (op_func)compute_##code
1742 * sets the generic functions to compute.
1744 static void set_compute_functions(void) {
1747 /* set the default compute function */
1748 for (i = get_irp_n_opcodes() - 1; i >= 0; --i) {
1749 ir_op *op = get_irp_opcode(i);
1750 op->ops.generic = (op_func)default_compute;
1753 /* set specific functions */
1766 } /* set_compute_functions */
1768 static int dump_partition_hook(FILE *F, ir_node *n, ir_node *local) {
1769 ir_node *irn = local != NULL ? local : n;
1770 node_t *node = get_irn_node(irn);
1772 ir_fprintf(F, "info2 : \"partition %u type %+F\"\n", node->part->nr, node->type);
1776 void combo(ir_graph *irg) {
1780 ir_graph *rem = current_ir_graph;
1782 current_ir_graph = irg;
1784 /* register a debug mask */
1785 FIRM_DBG_REGISTER(dbg, "firm.opt.combo");
1786 //firm_dbg_set_mask(dbg, SET_LEVEL_3);
1788 DB((dbg, LEVEL_1, "Doing COMBO for %+F\n", irg));
1790 obstack_init(&env.obst);
1791 env.worklist = NULL;
1795 #ifdef DEBUG_libfirm
1796 env.dbg_list = NULL;
1798 env.opcode2id_map = new_set(cmp_opcode, iro_Last * 4);
1799 env.type2id_map = pmap_create();
1800 env.end_idx = get_opt_global_cse() ? 0 : -1;
1801 env.lambda_input = 0;
1803 assure_irg_outs(irg);
1805 /* we have our own value_of function */
1806 set_value_of_func(get_node_tarval);
1808 set_compute_functions();
1809 DEBUG_ONLY(part_nr = 0);
1811 /* create the initial partition and place it on the work list */
1812 env.initial = new_partition(&env);
1813 add_to_worklist(env.initial, &env);
1814 irg_walk_graph(irg, init_block_phis, create_initial_partitions, &env);
1816 /* Place the START Node's partition on cprop.
1817 Place the START Node on its local worklist. */
1818 initial_X = get_irg_initial_exec(irg);
1819 start = get_irn_node(initial_X);
1820 add_node_to_cprop(start, &env);
1824 if (env.worklist != NULL)
1826 } while (env.cprop != NULL || env.worklist != NULL);
1828 dump_all_partitions(&env);
1830 set_dump_node_vcgattr_hook(dump_partition_hook);
1831 dump_ir_block_graph(irg, "-partition");
1832 set_dump_node_vcgattr_hook(NULL);
1835 /* apply the result */
1836 irg_block_walk_graph(irg, NULL, apply_cf, &env);
1837 irg_walk_graph(irg, NULL, apply_result, &env);
1839 pmap_destroy(env.type2id_map);
1840 del_set(env.opcode2id_map);
1841 obstack_free(&env.obst, NULL);
1843 /* restore value_of() default behavior */
1844 set_value_of_func(NULL);
1845 current_ir_graph = rem;