opt_ldst.c 56.2 KB
Newer Older
1
/*
2
 * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 *
 * This file is part of libFirm.
 *
 * This file may be distributed and/or modified under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation and appearing in the file LICENSE.GPL included in the
 * packaging of this file.
 *
 * Licensees holding valid libFirm Professional Edition licenses may use
 * this file in accordance with the libFirm Commercial License.
 * Agreement provided with the Software.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE.
 */

/**
 * @file
 * @brief   Dataflow driven Load/Store optimizations, uses some ideas from
 *          VanDrunen's LEPRE
 * @author  Michael Beck
 */
#include "config.h"

#include "irnode_t.h"
#include "irflag_t.h"
#include "array_t.h"
#include "ircons.h"
#include "irdom.h"
#include "irgmod.h"
#include "irgwalk.h"
#include "irouts.h"
#include "irgraph.h"
#include "irgopt.h"
Michael Beck's avatar
Michael Beck committed
38
39
#include "iropt.h"
#include "iroptimize.h"
40
#include "irnodehashmap.h"
41
42
43
#include "raw_bitset.h"
#include "debug.h"
#include "error.h"
44
#include "irpass.h"
45

46
/* maximum number of output Proj's */
47
#define MAX_PROJ ((long)pn_Load_max > (long)pn_Store_max ? (long)pn_Load_max : (long)pn_Store_max)
48

49
/**
50
 * Mapping an address to an dense ID.
51
52
53
54
55
56
57
58
59
 */
typedef struct address_entry_t {
	unsigned id;          /**< The ID */
} address_entry;

/**
 * Memop-flags.
 */
enum memop_flags {
60
61
62
63
	FLAG_KILL_ALL    = 1, /**< KILL all addresses */
	FLAG_KILLED_NODE = 2, /**< this node was killed */
	FLAG_EXCEPTION   = 4, /**< this node has exception flow */
	FLAG_IGNORE      = 8, /**< ignore this node (volatile or other) */
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
};

/**
 * A value: This represents a value stored at a given address in
 * memory. Do not confuse with values from value numbering.
 */
typedef struct value_t value_t;
struct value_t {
	ir_node  *address;    /**< the address of this value */
	ir_node  *value;      /**< the value itself */
	ir_mode  *mode;       /**< the mode of the value */
	unsigned id;          /**< address id */
};

/**
 * A memop describes an memory-related operation.
 * These are Loads/Store and all other ops that might modify
 * memory (Calls, CopyB) or causing exceptions.
 */
typedef struct memop_t memop_t;
struct memop_t {
	value_t  value;      /**< the value of this memop: only defined for Load/Store */
	ir_node  *node;      /**< the memory op itself */
	ir_node  *mem;       /**< the memory FROM this node */
	ir_node  *replace;   /**< the replacement node if this memop is replaced */
	memop_t  *next;      /**< links to the next memory op in the block in forward order. */
	memop_t  *prev;      /**< links to the previous memory op in the block in forward order. */
	unsigned flags;      /**< memop flags */
92
	ir_node  *projs[MAX_PROJ+1]; /**< Projs of this memory op */
93
94
95
96
97
98
99
100
101
102
103
104
};

/**
 * Additional data for every basic block.
 */
typedef struct block_t block_t;
struct block_t {
	memop_t  *memop_forward;     /**< topologically sorted list of memory ops in this block */
	memop_t  *memop_backward;    /**< last memop in the list */
	unsigned *avail_out;         /**< out-set of available addresses */
	memop_t  **id_2_memop_avail; /**< maps avail address ids to memops */
	unsigned *anticL_in;         /**< in-set of anticipated Load addresses */
Michael Beck's avatar
Michael Beck committed
105
	memop_t  **id_2_memop_antic; /**< maps anticipated address ids to memops */
106
107
108
109
	ir_node  *block;             /**< the associated block */
	block_t  *forward_next;      /**< next block entry for forward iteration */
	block_t  *backward_next;     /**< next block entry for backward iteration */
	memop_t  *avail;             /**< used locally for the avail map */
110
	memop_t  **trans_results;    /**< used to cached translated nodes due antic calculation. */
111
112
113
114
115
116
};

/**
 * Metadata for this pass.
 */
typedef struct ldst_env_t {
117
118
	struct obstack   obst;             /**< obstack for temporary data */
	ir_nodehashmap_t adr_map;          /**< Map addresses to */
Michael Beck's avatar
Michael Beck committed
119
120
121
122
123
124
125
126
	block_t         *forward;          /**< Inverse post-order list of all blocks Start->End */
	block_t         *backward;         /**< Inverse post-order list of all blocks End->Start */
	ir_node         *start_bl;         /**< start block of the current graph */
	ir_node         *end_bl;           /**< end block of the current graph */
	unsigned        *curr_set;         /**< current set of addresses */
	memop_t         **curr_id_2_memop; /**< current map of address ids to memops */
	unsigned        curr_adr_id;       /**< number for address mapping */
	unsigned        n_mem_ops;         /**< number of memory operations (Loads/Stores) */
127
	size_t          rbs_size;          /**< size of all bitsets in bytes */
128
	int             max_cfg_preds;     /**< maximum number of block cfg predecessors */
Michael Beck's avatar
Michael Beck committed
129
	int             changed;           /**< Flags for changed graph state */
130
131
132
#ifdef DEBUG_libfirm
	ir_node         **id_2_address;    /**< maps an id to the used address */
#endif
133
134
} ldst_env;

135
136
137
/* the one and only environment */
static ldst_env env;

138
139
140
141
142
143
144
145
146
#ifdef DEBUG_libfirm

static firm_dbg_module_t *dbg;

/**
 * Dumps the block list.
 *
 * @param ldst environment
 */
147
148
static void dump_block_list(ldst_env *env)
{
149
150
151
152
153
154
155
156
157
158
159
	block_t *entry;
	memop_t *op;
	int     i;

	for (entry = env->forward; entry != NULL; entry = entry->forward_next) {
		DB((dbg, LEVEL_2, "%+F {", entry->block));

		i = 0;
		for (op = entry->memop_forward; op != NULL; op = op->next) {
			if (i == 0) {
				DB((dbg, LEVEL_2, "\n\t"));
160
161
			}
			DB((dbg, LEVEL_2, "%+F", op->node));
162
163
			if ((op->flags & FLAG_KILL_ALL) == FLAG_KILL_ALL)
				DB((dbg, LEVEL_2, "X"));
164
165
			else if (op->flags & FLAG_KILL_ALL)
				DB((dbg, LEVEL_2, "K"));
166
167
168
169
170
171
			DB((dbg, LEVEL_2, ", "));

			i = (i + 1) & 3;
		}
		DB((dbg, LEVEL_2, "\n}\n\n"));
	}
172
}  /* dump_block_list */
173
174
175
176
177
178
179

/**
 * Dumps the current set.
 *
 * @param bl   current block
 * @param s    name of the set
 */
180
181
static void dump_curr(block_t *bl, const char *s)
{
182
183
184
	size_t end = env.rbs_size - 1;
	size_t pos;
	int    i;
185
186
187

	DB((dbg, LEVEL_2, "%s[%+F] = {", s, bl->block));
	i = 0;
188
	for (pos = rbitset_next(env.curr_set, 0, 1); pos < end; pos = rbitset_next(env.curr_set, pos + 1, 1)) {
Michael Beck's avatar
Michael Beck committed
189
		memop_t *op = env.curr_id_2_memop[pos];
190
191
192
193

		if (i == 0) {
			DB((dbg, LEVEL_2, "\n\t"));
		}
194

195
196
197
198
		DB((dbg, LEVEL_2, "<%+F, %+F>, ", op->value.address, op->value.value));
		i = (i + 1) & 3;
	}
	DB((dbg, LEVEL_2, "\n}\n"));
199
}  /* dump_curr */
200
201

#else
202
203
static void dump_block_list(ldst_env *env)
{
204
205
	(void) env;
}
206
207
static void dump_curr(block_t *bl, const char *s)
{
208
209
210
	(void) bl;
	(void) s;
}
211
212
#endif /* DEBUG_libfirm */

213
/** Get the block entry for a block node */
214
215
static block_t *get_block_entry(const ir_node *block)
{
216
217
	assert(is_Block(block));

218
	return (block_t*)get_irn_link(block);
219
}  /* get_block_entry */
220
221

/** Get the memop entry for a memory operation node */
222
223
static memop_t *get_irn_memop(const ir_node *irn)
{
224
	assert(! is_Block(irn));
225
	return (memop_t*)get_irn_link(irn);
226
}  /* get_irn_memop */
227

228
229
/**
 * Walk over the memory edges from definition to users.
Michael Beck's avatar
Michael Beck committed
230
 * This ensures, that even operation without memory output are found.
231
232
233
234
235
236
 *
 * @param irn   start node
 * @param pre   pre walker function
 * @param post  post walker function
 * @param ctx   context parameter for the walker functions
 */
237
238
static void walk_memory(ir_node *irn, irg_walk_func *pre, irg_walk_func *post, void *ctx)
{
239
240
241
242
243
244
245
246
247
248
	ir_mode *mode;

	mark_irn_visited(irn);

	if (pre)
		pre(irn, ctx);

	mode = get_irn_mode(irn);
	if (mode == mode_M) {
		/* every successor uses memory */
Matthias Braun's avatar
Matthias Braun committed
249
		for (unsigned i = get_irn_n_outs(irn); i-- > 0; ) {
250
251
252
253
254
255
256
			ir_node *succ = get_irn_out(irn, i);

			if (! irn_visited(succ))
				walk_memory(succ, pre, post, ctx);
		}
	} else if (mode == mode_T) {
		/* only some Proj's uses memory */
Matthias Braun's avatar
Matthias Braun committed
257
		for (unsigned i = get_irn_n_outs(irn); i-- > 0; ) {
258
259
260
261
262
263
264
265
			ir_node *proj = get_irn_out(irn, i);

			if (get_irn_mode(proj) == mode_M && ! irn_visited(proj))
				walk_memory(proj, pre, post, ctx);
		}
	}
	if (post)
		post(irn, ctx);
266
}  /* walk_memory */
267
268
269
270
271
272
273
274
275

/**
 * Walks over all memory nodes of a graph.
 *
 * @param irg   a graph
 * @param pre   pre walker function
 * @param post  post walker function
 * @param ctx   context parameter for the walker functions
 */
276
277
static void walk_memory_irg(ir_graph *irg, irg_walk_func pre, irg_walk_func post, void *ctx)
{
278
279
280
281
282
283
284
285
286
287
288
	inc_irg_visited(irg);

	ir_reserve_resources(irg, IR_RESOURCE_IRN_VISITED);

	/*
	 * there are two possible sources for memory: initial_mem and nomem
	 * we ignore nomem as this should NOT change the memory
	 */
	walk_memory(get_irg_initial_mem(irg), pre, post, ctx);

	ir_free_resources(irg, IR_RESOURCE_IRN_VISITED);
289
}  /* walk_memory_irg */
290
291

/**
292
293
294
295
296
297
 * Register an address and allocate a (sparse, 0..n) ID for it.
 *
 * @param adr  the IR-node representing the address
 *
 * @return the allocated id
 */
298
299
static unsigned register_address(ir_node *adr)
{
300
301
302
303
304
305
306
307
308
309
310
311
312
	address_entry *entry;

	/* skip Confirms and Casts */
restart:
	if (is_Confirm(adr)) {
		adr = get_Confirm_value(adr);
		goto restart;
	}
	if (is_Cast(adr)) {
		adr = get_Cast_op(adr);
		goto restart;
	}

313
	entry = ir_nodehashmap_get(address_entry, &env.adr_map, adr);
314
315
316

	if (entry == NULL) {
		/* new address */
317
		entry = OALLOC(&env.obst, address_entry);
318
319

		entry->id = env.curr_adr_id++;
320
		ir_nodehashmap_insert(&env.adr_map, adr, entry);
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338

		DB((dbg, LEVEL_3, "ADDRESS %+F has ID %u\n", adr, entry->id));
#ifdef DEBUG_libfirm
		ARR_APP1(ir_node *, env.id_2_address, adr);
#endif
	}
	return entry->id;
}  /* register_address */


/**
 * translate an address through a Phi node into a given predecessor
 * block.
 *
 * @param address  the address
 * @param block    the block
 * @param pos      the position of the predecessor in block
 */
339
340
static ir_node *phi_translate(ir_node *address, const ir_node *block, int pos)
{
341
342
343
344
345
346
347
348
	if (is_Phi(address) && get_nodes_block(address) == block)
		address = get_Phi_pred(address, pos);
	return address;
}  /* phi_translate */

/**
 * Walker: allocate an block entry for every block
 * and register all potential addresses.
349
 */
350
351
static void prepare_blocks(ir_node *irn, void *ctx)
{
352
	(void)ctx;
353

354
	if (is_Block(irn)) {
355
		block_t *entry = OALLOC(&env.obst, block_t);
356
357
358
359
360
361
362
363
		int     n;

		entry->memop_forward    = NULL;
		entry->memop_backward   = NULL;
		entry->avail_out        = NULL;
		entry->id_2_memop_avail = NULL;
		entry->anticL_in        = NULL;
		entry->id_2_memop_antic = NULL;
364
		entry->block            = irn;
365
366
367
		entry->forward_next     = NULL;
		entry->backward_next    = NULL;
		entry->avail            = NULL;
368
369
		entry->trans_results    = NULL;
		set_irn_link(irn, entry);
370

371
		set_Block_phis(irn, NULL);
372
373

		/* use block marks to track unreachable blocks */
374
		set_Block_mark(irn, 0);
375

376
		n = get_Block_n_cfgpreds(irn);
377
378
		if (n > env.max_cfg_preds)
			env.max_cfg_preds = n;
379
380
381
382
383
384
385
386
387
388
389
	} else {
		ir_mode *mode = get_irn_mode(irn);

		if (mode_is_reference(mode)) {
			/*
			 * Register ALL possible addresses: this is overkill yet but
			 * simpler then doing it for all possible translated addresses
			 * (which would be sufficient in the moment.
			 */
			(void)register_address(irn);
		}
390
	}
391
}  /* prepare_blocks */
392
393
394
395

/**
 * Post-Walker, link in all Phi's
 */
396
397
static void link_phis(ir_node *irn, void *ctx)
{
398
	(void)ctx;
399

400
401
402
403
	if (is_Phi(irn)) {
		ir_node *block = get_nodes_block(irn);
		add_Block_phi(block, irn);
	}
404
}  /* link_phis */
405
406
407
408

/**
 * Block walker: creates the inverse post-order list for the CFG.
 */
409
410
static void inverse_post_order(ir_node *block, void *ctx)
{
411
412
413
	block_t *entry = get_block_entry(block);

	(void)ctx;
414

415
416
417
	/* mark this block IS reachable from start */
	set_Block_mark(block, 1);

418
	/* create the list in inverse order */
419
420
421
422
423
424
	entry->forward_next = env.forward;
	env.forward         = entry;

	/* remember the first visited (last in list) entry, needed for later */
	if (env.backward == NULL)
		env.backward = entry;
425
}  /* inverse_post_order */
426
427
428
429

/**
 * Block walker: create backward links for the memops of a block.
 */
430
431
static void collect_backward(ir_node *block, void *ctx)
{
432
433
434
	block_t *entry = get_block_entry(block);
	memop_t *last, *op;

435
	(void)ctx;
436

437
438
439
440
441
442
443
444
445
446
447
	/*
	 * Do NOT link in the end block yet. We want it to be
	 * the first in the list. This is NOT guaranteed by the walker
	 * if we have endless loops.
	 */
	if (block != env.end_bl) {
		entry->backward_next = env.backward;

		/* create the list in inverse order */
		env.backward = entry;
	}
448
449
450
451
452
453
454
455

	/* create backward links for all memory ops */
	last = NULL;
	for (op = entry->memop_forward; op != NULL; op = op->next) {
		op->prev = last;
		last     = op;
	}
	entry->memop_backward = last;
456
}  /* collect_backward */
457
458
459
460

/**
 * Allocate a memop.
 *
461
462
463
464
 * @param irn  the IR-node representing the memop or NULL
 *             if this is a translated (virtual) memop
 *
 * @return the allocated memop
465
 */
466
467
static memop_t *alloc_memop(ir_node *irn)
{
468
	memop_t *m = OALLOC(&env.obst, memop_t);
469
470
471
472
473
474

	m->value.address = NULL;
	m->value.value   = NULL;
	m->value.mode    = NULL;

	m->node          = irn;
Michael Beck's avatar
Michael Beck committed
475
	m->mem           = NULL;
476
477
478
479
	m->replace       = NULL;
	m->next          = NULL;
	m->flags         = 0;

480
481
	memset(m->projs, 0, sizeof(m->projs));

482
483
	if (irn != NULL)
		set_irn_link(irn, m);
484
	return m;
485
}  /* alloc_memop */
486

Michael Beck's avatar
Michael Beck committed
487
488
489
490
491
492
/**
 * Create a memop for a Phi-replacement.
 *
 * @param op   the memop to clone
 * @param phi  the Phi-node representing the new value
 */
493
494
static memop_t *clone_memop_phi(memop_t *op, ir_node *phi)
{
495
	memop_t *m = OALLOC(&env.obst, memop_t);
Michael Beck's avatar
Michael Beck committed
496
497
498
499
500
501
502
503
504
505
506

	m->value         = op->value;
	m->value.value   = phi;

	m->node          = phi;
	m->replace       = NULL;
	m->next          = NULL;
	m->flags         = 0;

	set_irn_link(phi, m);
	return m;
507
}  /* clone_memop_phi */
508
509
510
511
512
513
514
515

/**
 * Return the memory properties of a call node.
 *
 * @param call  the call node
 *
 * return a bitset of mtp_property_const and mtp_property_pure
 */
516
517
static unsigned get_Call_memory_properties(ir_node *call)
{
518
519
520
521
522
523
524
525
	ir_type *call_tp = get_Call_type(call);
	unsigned prop = get_method_additional_properties(call_tp);

	/* check first the call type */
	if ((prop & (mtp_property_const|mtp_property_pure)) == 0) {
		/* try the called entity */
		ir_node *ptr = get_Call_ptr(call);

526
527
		if (is_SymConst_addr_ent(ptr)) {
			ir_entity *ent = get_SymConst_entity(ptr);
528
529
530
531
532

			prop = get_entity_additional_properties(ent);
		}
	}
	return prop & (mtp_property_const|mtp_property_pure);
533
}  /* get_Call_memory_properties */
534

Michael Beck's avatar
Michael Beck committed
535
536
537
538
539
540
541
/**
 * Returns an entity if the address ptr points to a constant one.
 *
 * @param ptr  the address
 *
 * @return an entity or NULL
 */
542
543
static ir_entity *find_constant_entity(ir_node *ptr)
{
Michael Beck's avatar
Michael Beck committed
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
	for (;;) {
		if (is_SymConst(ptr) && get_SymConst_kind(ptr) == symconst_addr_ent) {
			return get_SymConst_entity(ptr);
		} else if (is_Sel(ptr)) {
			ir_entity *ent = get_Sel_entity(ptr);
			ir_type   *tp  = get_entity_owner(ent);

			/* Do not fiddle with polymorphism. */
			if (is_Class_type(get_entity_owner(ent)) &&
				((get_entity_n_overwrites(ent)    != 0) ||
				(get_entity_n_overwrittenby(ent) != 0)   ) )
				return NULL;

			if (is_Array_type(tp)) {
				/* check bounds */
				int i, n;

				for (i = 0, n = get_Sel_n_indexs(ptr); i < n; ++i) {
Matthias Braun's avatar
Matthias Braun committed
562
563
564
565
					ir_node   *bound;
					ir_tarval *tlower, *tupper;
					ir_node   *index = get_Sel_index(ptr, i);
					ir_tarval *tv     = computed_value(index);
Michael Beck's avatar
Michael Beck committed
566
567
568
569
570
571
572
573
574
575
576
577
578

					/* check if the index is constant */
					if (tv == tarval_bad)
						return NULL;

					bound  = get_array_lower_bound(tp, i);
					tlower = computed_value(bound);
					bound  = get_array_upper_bound(tp, i);
					tupper = computed_value(bound);

					if (tlower == tarval_bad || tupper == tarval_bad)
						return NULL;

579
					if (tarval_cmp(tv, tlower) == ir_relation_less)
Michael Beck's avatar
Michael Beck committed
580
						return NULL;
581
					if (tarval_cmp(tupper, tv) == ir_relation_less)
Michael Beck's avatar
Michael Beck committed
582
583
584
585
586
587
						return NULL;

					/* ok, bounds check finished */
				}
			}

Matthias Braun's avatar
Matthias Braun committed
588
			if (get_entity_linkage(ent) == IR_LINKAGE_CONSTANT)
Michael Beck's avatar
Michael Beck committed
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
				return ent;

			/* try next */
			ptr = get_Sel_ptr(ptr);
		} else if (is_Add(ptr)) {
			ir_node *l = get_Add_left(ptr);
			ir_node *r = get_Add_right(ptr);

			if (get_irn_mode(l) == get_irn_mode(ptr) && is_Const(r))
				ptr = l;
			else if (get_irn_mode(r) == get_irn_mode(ptr) && is_Const(l))
				ptr = r;
			else
				return NULL;

			/* for now, we support only one addition, reassoc should fold all others */
			if (! is_SymConst(ptr) && !is_Sel(ptr))
				return NULL;
		} else if (is_Sub(ptr)) {
			ir_node *l = get_Sub_left(ptr);
			ir_node *r = get_Sub_right(ptr);

611
			if (get_irn_mode(l) == get_irn_mode(ptr) && is_Const(r))
Michael Beck's avatar
Michael Beck committed
612
613
614
615
616
617
618
619
620
621
622
623
624
625
				ptr = l;
			else
				return NULL;
			/* for now, we support only one subtraction, reassoc should fold all others */
			if (! is_SymConst(ptr) && !is_Sel(ptr))
				return NULL;
		} else
			return NULL;
	}
}  /* find_constant_entity */

/**
 * Return the Selection index of a Sel node from dimension n
 */
626
627
static long get_Sel_array_index_long(ir_node *n, int dim)
{
Michael Beck's avatar
Michael Beck committed
628
629
630
631
632
633
634
635
	ir_node *index = get_Sel_index(n, dim);
	assert(is_Const(index));
	return get_tarval_long(get_Const_tarval(index));
}  /* get_Sel_array_index_long */

typedef struct path_entry {
	ir_entity         *ent;
	struct path_entry *next;
636
	size_t            index;
Michael Beck's avatar
Michael Beck committed
637
638
} path_entry;

639
640
static ir_node *rec_find_compound_ent_value(ir_node *ptr, path_entry *next)
{
Michael Beck's avatar
Michael Beck committed
641
642
643
	path_entry       entry, *p;
	ir_entity        *ent, *field;
	ir_initializer_t *initializer;
Matthias Braun's avatar
Matthias Braun committed
644
	ir_tarval        *tv;
Michael Beck's avatar
Michael Beck committed
645
	ir_type          *tp;
646
	size_t           n;
Michael Beck's avatar
Michael Beck committed
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668

	entry.next = next;
	if (is_SymConst(ptr)) {
		/* found the root */
		ent         = get_SymConst_entity(ptr);
		initializer = get_entity_initializer(ent);
		for (p = next; p != NULL;) {
			if (initializer->kind != IR_INITIALIZER_COMPOUND)
				return NULL;
			n  = get_initializer_compound_n_entries(initializer);
			tp = get_entity_type(ent);

			if (is_Array_type(tp)) {
				ent = get_array_element_entity(tp);
				if (ent != p->ent) {
					/* a missing [0] */
					if (0 >= n)
						return NULL;
					initializer = get_initializer_compound_value(initializer, 0);
					continue;
				}
			}
669
			if (p->index >= n)
Michael Beck's avatar
Michael Beck committed
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
				return NULL;
			initializer = get_initializer_compound_value(initializer, p->index);

			ent = p->ent;
			p   = p->next;
		}
		tp = get_entity_type(ent);
		while (is_Array_type(tp)) {
			ent = get_array_element_entity(tp);
			tp = get_entity_type(ent);
			/* a missing [0] */
			n  = get_initializer_compound_n_entries(initializer);
			if (0 >= n)
				return NULL;
			initializer = get_initializer_compound_value(initializer, 0);
		}

		switch (initializer->kind) {
		case IR_INITIALIZER_CONST:
			return get_initializer_const_value(initializer);
		case IR_INITIALIZER_TARVAL:
		case IR_INITIALIZER_NULL:
		default:
			return NULL;
		}
	} else if (is_Sel(ptr)) {
		entry.ent = field = get_Sel_entity(ptr);
		tp = get_entity_owner(field);
		if (is_Array_type(tp)) {
			assert(get_Sel_n_indexs(ptr) == 1 && "multi dim arrays not implemented");
			entry.index = get_Sel_array_index_long(ptr, 0) - get_array_lower_bound_int(tp, 0);
		} else {
702
			size_t i, n_members = get_compound_n_members(tp);
Michael Beck's avatar
Michael Beck committed
703
704
705
706
707
708
709
710
711
712
713
714
			for (i = 0; i < n_members; ++i) {
				if (get_compound_member(tp, i) == field)
					break;
			}
			if (i >= n_members) {
				/* not found: should NOT happen */
				return NULL;
			}
			entry.index = i;
		}
		return rec_find_compound_ent_value(get_Sel_ptr(ptr), &entry);
	}  else if (is_Add(ptr)) {
715
		ir_mode *mode;
Michael Beck's avatar
Michael Beck committed
716
717
		unsigned pos;

718
719
720
721
722
723
724
725
726
727
		{
			ir_node *l = get_Add_left(ptr);
			ir_node *r = get_Add_right(ptr);
			if (is_Const(r)) {
				ptr = l;
				tv  = get_Const_tarval(r);
			} else {
				ptr = r;
				tv  = get_Const_tarval(l);
			}
Michael Beck's avatar
Michael Beck committed
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
		}
ptr_arith:
		mode = get_tarval_mode(tv);

		/* ptr must be a Sel or a SymConst, this was checked in find_constant_entity() */
		if (is_Sel(ptr)) {
			field = get_Sel_entity(ptr);
		} else {
			field = get_SymConst_entity(ptr);
		}

		/* count needed entries */
		pos = 0;
		for (ent = field;;) {
			tp = get_entity_type(ent);
			if (! is_Array_type(tp))
				break;
			ent = get_array_element_entity(tp);
			++pos;
		}
		/* should be at least ONE entry */
		if (pos == 0)
			return NULL;

		/* allocate the right number of entries */
		NEW_ARR_A(path_entry, p, pos);

		/* fill them up */
		pos = 0;
		for (ent = field;;) {
Matthias Braun's avatar
Matthias Braun committed
758
759
			unsigned  size;
			ir_tarval *sz, *tv_index, *tlower, *tupper;
760
			size_t    index;
Matthias Braun's avatar
Matthias Braun committed
761
			ir_node   *bound;
Michael Beck's avatar
Michael Beck committed
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787

			tp = get_entity_type(ent);
			if (! is_Array_type(tp))
				break;
			ent = get_array_element_entity(tp);
			p[pos].ent  = ent;
			p[pos].next = &p[pos + 1];

			size = get_type_size_bytes(get_entity_type(ent));
			sz   = new_tarval_from_long(size, mode);

			tv_index = tarval_div(tv, sz);
			tv       = tarval_mod(tv, sz);

			if (tv_index == tarval_bad || tv == tarval_bad)
				return NULL;

			assert(get_array_n_dimensions(tp) == 1 && "multiarrays not implemented");
			bound  = get_array_lower_bound(tp, 0);
			tlower = computed_value(bound);
			bound  = get_array_upper_bound(tp, 0);
			tupper = computed_value(bound);

			if (tlower == tarval_bad || tupper == tarval_bad)
				return NULL;

788
			if (tarval_cmp(tv_index, tlower) == ir_relation_less)
Michael Beck's avatar
Michael Beck committed
789
				return NULL;
790
			if (tarval_cmp(tupper, tv_index) == ir_relation_less)
Michael Beck's avatar
Michael Beck committed
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
				return NULL;

			/* ok, bounds check finished */
			index = get_tarval_long(tv_index);
			p[pos].index = index;
			++pos;
		}
		if (! tarval_is_null(tv)) {
			/* hmm, wrong access */
			return NULL;
		}
		p[pos - 1].next = next;
		return rec_find_compound_ent_value(ptr, p);
	} else if (is_Sub(ptr)) {
		ir_node *l = get_Sub_left(ptr);
		ir_node *r = get_Sub_right(ptr);

		ptr = l;
		tv  = get_Const_tarval(r);
		tv  = tarval_neg(tv);
		goto ptr_arith;
	}
	return NULL;
}  /* rec_find_compound_ent_value */

816
817
static ir_node *find_compound_ent_value(ir_node *ptr)
{
Michael Beck's avatar
Michael Beck committed
818
819
820
821
822
823
824
825
	return rec_find_compound_ent_value(ptr, NULL);
}  /* find_compound_ent_value */

/**
 * Mark a Load memop to be replace by a definition
 *
 * @param op  the Load memop
 */
826
827
static void mark_replace_load(memop_t *op, ir_node *def)
{
Michael Beck's avatar
Michael Beck committed
828
829
830
831
832
833
834
835
836
837
	op->replace = def;
	op->flags |= FLAG_KILLED_NODE;
	env.changed = 1;
}  /* mark_replace_load */

/**
 * Mark a Store memop to be removed.
 *
 * @param op  the Store memop
 */
838
839
static void mark_remove_store(memop_t *op)
{
Michael Beck's avatar
Michael Beck committed
840
841
842
843
	op->flags |= FLAG_KILLED_NODE;
	env.changed = 1;
}  /* mark_remove_store */

844
845
846
847
848
/**
 * Update a memop for a Load.
 *
 * @param m  the memop
 */
849
850
static void update_Load_memop(memop_t *m)
{
Michael Beck's avatar
Michael Beck committed
851
852
853
	ir_node   *load = m->node;
	ir_node   *ptr;
	ir_entity *ent;
854
855
856
857

	if (get_Load_volatility(load) == volatility_is_volatile)
		m->flags |= FLAG_IGNORE;

Michael Beck's avatar
Michael Beck committed
858
859
860
	ptr = get_Load_ptr(load);

	m->value.address = ptr;
861

Matthias Braun's avatar
Matthias Braun committed
862
	for (unsigned i = get_irn_n_outs(load); i-- > 0; ) {
863
		ir_node *proj = get_irn_out(load, i);
864
		long    pn;
865

866
867
868
869
		/* beware of keep edges */
		if (is_End(proj))
			continue;

870
871
872
		pn = get_Proj_proj(proj);
		m->projs[pn] = proj;
		switch (pn) {
873
874
875
876
877
878
879
880
881
882
		case pn_Load_res:
			m->value.value = proj;
			m->value.mode  = get_irn_mode(proj);
			break;
		case pn_Load_X_except:
			m->flags |= FLAG_EXCEPTION;
			break;
		case pn_Load_M:
			m->mem = proj;
			break;
883
884
885
886
		case pn_Load_X_regular:
			break;
		default:
			panic("Unsupported Proj from Load %+F", proj);
887
888
889
		}
	}

Michael Beck's avatar
Michael Beck committed
890
891
892
	/* check if we can determine the entity that will be loaded */
	ent = find_constant_entity(ptr);

893
	if (ent != NULL && get_entity_visibility(ent) != ir_visibility_external) {
Michael Beck's avatar
Michael Beck committed
894
895
896
897
898
899
		/* a static allocation that is not external: there should be NO exception
		 * when loading even if we cannot replace the load itself. */
		ir_node *value = NULL;

		/* no exception, clear the m fields as it might be checked later again */
		if (m->projs[pn_Load_X_except]) {
900
			ir_graph *irg = get_irn_irg(ptr);
Matthias Braun's avatar
Matthias Braun committed
901
			exchange(m->projs[pn_Load_X_except], new_r_Bad(irg, mode_X));
Michael Beck's avatar
Michael Beck committed
902
903
904
905
906
			m->projs[pn_Load_X_except] = NULL;
			m->flags &= ~FLAG_EXCEPTION;
			env.changed = 1;
		}
		if (m->projs[pn_Load_X_regular]) {
907
			exchange(m->projs[pn_Load_X_regular], new_r_Jmp(get_nodes_block(load)));
Michael Beck's avatar
Michael Beck committed
908
909
910
911
			m->projs[pn_Load_X_regular] = NULL;
			env.changed = 1;
		}

Matthias Braun's avatar
Matthias Braun committed
912
913
		if (get_entity_linkage(ent) & IR_LINKAGE_CONSTANT) {
			if (ent->initializer) {
Michael Beck's avatar
Michael Beck committed
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
				/* new style initializer */
				value = find_compound_ent_value(ptr);
			}
			if (value != NULL)
				value = can_replace_load_by_const(load, value);
		}

		if (value != NULL) {
			/* we completely replace the load by this value */
			DB((dbg, LEVEL_1, "Replacing Load %+F by constant %+F\n", m->node, value));
			mark_replace_load(m, value);
			return;
		}
	}

929
930
	if (m->value.value != NULL && !(m->flags & FLAG_IGNORE)) {
		/* only create an address if this node is NOT killed immediately or ignored */
Michael Beck's avatar
Michael Beck committed
931
		m->value.id = register_address(ptr);
932
933
934
		++env.n_mem_ops;
	} else {
		/* no user, KILL it */
935
		mark_replace_load(m, NULL);
936
	}
937
}  /* update_Load_memop */
938
939
940
941
942
943

/**
 * Update a memop for a Store.
 *
 * @param m  the memop
 */
944
945
static void update_Store_memop(memop_t *m)
{
946
947
948
949
950
951
952
953
954
955
956
957
958
	ir_node *store = m->node;
	ir_node *adr   = get_Store_ptr(store);

	if (get_Store_volatility(store) == volatility_is_volatile) {
		m->flags |= FLAG_IGNORE;
	} else {
		/* only create an address if this node is NOT ignored */
		m->value.id = register_address(adr);
		++env.n_mem_ops;
	}

	m->value.address = adr;

Matthias Braun's avatar
Matthias Braun committed
959
	for (unsigned i = get_irn_n_outs(store); i-- > 0; ) {
960
		ir_node *proj = get_irn_out(store, i);
961
		long    pn;
962

963
964
965
966
		/* beware of keep edges */
		if (is_End(proj))
			continue;

967
968
969
		pn = get_Proj_proj(proj);
		m->projs[pn] = proj;
		switch (pn) {
970
971
972
973
974
975
		case pn_Store_X_except:
			m->flags |= FLAG_EXCEPTION;
			break;
		case pn_Store_M:
			m->mem = proj;
			break;
976
977
978
979
		case pn_Store_X_regular:
			break;
		default:
			panic("Unsupported Proj from Store %+F", proj);
980
981
982
983
		}
	}
	m->value.value = get_Store_value(store);
	m->value.mode  = get_irn_mode(m->value.value);
984
}  /* update_Store_memop */
985
986
987
988
989
990

/**
 * Update a memop for a Call.
 *
 * @param m  the memop
 */
991
992
static void update_Call_memop(memop_t *m)
{
993
994
995
996
997
998
999
1000
	ir_node  *call = m->node;
	unsigned prop  = get_Call_memory_properties(call);

	if (prop & mtp_property_const) {
		/* A constant call did NOT use memory at all, we
		   can kick it from the list. */
	} else if (prop & mtp_property_pure) {
		/* pure calls READ memory */
1001
		m->flags = 0;
1002
1003
1004
	} else
		m->flags = FLAG_KILL_ALL;

Matthias Braun's avatar
Matthias Braun committed
1005
	for (unsigned i = get_irn_n_outs(call); i-- > 0; ) {
1006
1007
		ir_node *proj = get_irn_out(call, i);

1008
1009
1010
1011
		/* beware of keep edges */
		if (is_End(proj))
			continue;

1012
1013
1014
1015
		switch (get_Proj_proj(proj)) {
		case pn_Call_X_except:
			m->flags |= FLAG_EXCEPTION;
			break;
1016
		case pn_Call_M:
1017
1018
1019
1020
			m->mem = proj;
			break;
		}
	}
1021
}  /* update_Call_memop */
1022
1023

/**
1024
 * Update a memop for a Div/Mod.
1025
1026
1027
 *
 * @param m  the memop
 */
Matthias Braun's avatar
Matthias Braun committed
1028
static void update_Div_memop(memop_t *m)
1029
{
1030
1031
	ir_node *div = m->node;

Matthias Braun's avatar
Matthias Braun committed
1032
	for (unsigned i = get_irn_n_outs(div); i-- > 0; ) {
1033
1034
		ir_node *proj = get_irn_out(div, i);

1035
1036
1037
1038
		/* beware of keep edges */
		if (is_End(proj))
			continue;

1039
		switch (get_Proj_proj(proj)) {
Matthias Braun's avatar
Matthias Braun committed
1040
		case pn_Div_X_except:
1041
1042
			m->flags |= FLAG_EXCEPTION;
			break;
Matthias Braun's avatar
Matthias Braun committed
1043
		case pn_Div_M:
1044
1045
1046
1047
			m->mem = proj;
			break;
		}
	}
Matthias Braun's avatar
Matthias Braun committed
1048
1049
1050
1051
1052
1053
}

static void update_Mod_memop(memop_t *m)
{
	ir_node *div = m->node;

Matthias Braun's avatar
Matthias Braun committed
1054
	for (unsigned i = get_irn_n_outs(div); i-- > 0; ) {
Matthias Braun's avatar
Matthias Braun committed
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
		ir_node *proj = get_irn_out(div, i);

		/* beware of keep edges */
		if (is_End(proj))
			continue;

		switch (get_Proj_proj(proj)) {
		case pn_Mod_X_except:
			m->flags |= FLAG_EXCEPTION;
			break;
		case pn_Mod_M:
			m->mem = proj;
			break;
		}
	}
}
1071

Michael Beck's avatar
Michael Beck committed
1072
1073
1074
1075
1076
/**
 * Update a memop for a Phi.
 *
 * @param m  the memop
 */
1077
1078
static void update_Phi_memop(memop_t *m)
{
1079
	/* the Phi is its own mem */
Michael Beck's avatar
Michael Beck committed
1080
	m->mem = m->node;
1081
}  /* update_Phi_memop */
Michael Beck's avatar
Michael Beck committed
1082

1083
1084
1085
/**
 * Memory walker: collect all memory ops and build topological lists.
 */
1086
1087
static void collect_memops(ir_node *irn, void *ctx)
{
1088
1089
1090
1091
	memop_t  *op;
	ir_node  *block;
	block_t  *entry;

Michael Beck's avatar
Michael Beck committed
1092
	(void) ctx;
1093
1094
	if (is_Proj(irn)) {
		/* we can safely ignore ProjM's except the initial memory */
1095
1096
		ir_graph *irg = get_irn_irg(irn);
		if (irn != get_irg_initial_mem(irg))
1097
1098
1099
1100
1101
1102
1103
1104
			return;
	}

	op    = alloc_memop(irn);
	block = get_nodes_block(irn);
	entry = get_block_entry(block);

	if (is_Phi(irn)) {
Michael Beck's avatar
Michael Beck committed
1105
		update_Phi_memop(op);
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
		/* Phis must be always placed first */
		op->next = entry->memop_forward;
		entry->memop_forward = op;
		if (entry->memop_backward == NULL)
			entry->memop_backward = op;
	} else {
		switch (get_irn_opcode(irn)) {
		case iro_Load:
			update_Load_memop(op);
			break;
		case iro_Store:
			update_Store_memop(op);
			break;
		case iro_Call:
			update_Call_memop(op);
			break;
		case iro_Sync:
		case iro_Pin:
			op->mem = irn;
			break;
		case iro_Proj:
			/* initial memory */
			op->mem = irn;
			break;
		case iro_Return:
		case iro_End:
			/* we can those to find the memory edge */
			break;
		case iro_Div:
Matthias Braun's avatar
Matthias Braun committed
1135
1136
			update_Div_memop(op);
			break;
1137
		case iro_Mod:
Matthias Braun's avatar
Matthias Braun committed
1138
			update_Mod_memop(op);
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
			break;

		case iro_Builtin:
			/* TODO: handle some builtins */
		default:
			/* unsupported operation */
			op->flags = FLAG_KILL_ALL;
		}


		/* all other should be placed last */
		if (entry->memop_backward == NULL) {
			entry->memop_forward = entry->memop_backward = op;
		} else {
			entry->memop_backward->next = op;
			entry->memop_backward       = op;
		}
	}
1157
}  /* collect_memops */
1158
1159
1160
1161
1162

/**
 * Find an address in the current set.
 *
 * @param value  the value to be searched for
1163
1164
1165
1166
 *
 * @return a memop for the value or NULL if the value does
 *         not exists in the set or cannot be converted into
 *         the requested mode
1167
 */
1168
1169
static memop_t *find_address(const value_t *value)
{
1170
	if (rbitset_is_set(env.curr_set, value->id)) {
Michael Beck's avatar
Michael Beck committed
1171
		memop_t *res = env.curr_id_2_memop[value->id];
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181

		if (res->value.mode == value->mode)
			return res;
		/* allow hidden casts */
		if (get_mode_arithmetic(res->value.mode) == irma_twos_complement &&
		    get_mode_arithmetic(value->mode) == irma_twos_complement &&
		    get_mode_size_bits(res->value.mode) == get_mode_size_bits(value->mode))
			return res;
	}
	return NULL;
1182
}  /* find_address */
1183
1184
1185
1186
1187
1188

/**
 * Find an address in the avail_out set.
 *
 * @param bl     the block
 */
1189
1190
static memop_t *find_address_avail(const block_t *bl, unsigned id, const ir_mode *mode)
{
Michael Beck's avatar
Michael Beck committed
1191
1192
	if (rbitset_is_set(bl->avail_out, id)) {
		memop_t *res = bl->id_2_memop_avail[id];
1193

Michael Beck's avatar
Michael Beck committed
1194
		if (res->value.mode == mode)
1195
1196
1197
			return res;
		/* allow hidden casts */
		if (get_mode_arithmetic(res->value.mode) == irma_twos_complement &&
Michael Beck's avatar
Michael Beck committed
1198
1199
		    get_mode_arithmetic(mode) == irma_twos_complement &&
		    get_mode_size_bits(res->value.mode) == get_mode_size_bits(mode))
1200
1201
1202
			return res;
	}
	return NULL;
1203
}  /* find_address_avail */
1204
1205
1206
1207

/**
 * Kill all addresses from the current set.
 */
1208
1209
static void kill_all(void)
{
1210
1211
1212
1213
	rbitset_clear_all(env.curr_set, env.rbs_size);

	/* set sentinel */
	rbitset_set(env.curr_set, env.rbs_size - 1);
1214
}  /* kill_all */
1215
1216
1217
1218
1219
1220

/**
 * Kill memops that are not alias free due to a Store value from the current set.
 *
 * @param value  the Store value
 */
1221
1222
static void kill_memops(const value_t *value)
{
1223
1224
	size_t end = env.rbs_size - 1;
	size_t pos;
1225

1226
	for (pos = rbitset_next(env.curr_set, 0, 1); pos < end; pos = rbitset_next(env.curr_set, pos + 1, 1)) {
Michael Beck's avatar
Michael Beck committed
1227
		memop_t *op = env.curr_id_2_memop[pos];
1228

1229
		if (ir_no_alias != get_alias_relation(value->address, value->mode,
1230
1231
			                                  op->value.address, op->value.mode)) {
			rbitset_clear(env.curr_set, pos);
Michael Beck's avatar
Michael Beck committed
1232
			env.curr_id_2_memop[pos] = NULL;
1233
			DB((dbg, LEVEL_2, "KILLING %+F because of possible alias address %+F\n", op->node, value->address));
1234
1235
		}
	}
1236
}  /* kill_memops */
1237
1238
1239
1240
1241
1242

/**
 * Add the value of a memop to the current set.
 *
 * @param op  the memory op
 */
1243
1244
static void add_memop(memop_t *op)
{
1245
	rbitset_set(env.curr_set, op->value.id);
Michael Beck's avatar
Michael Beck committed
1246
	env.curr_id_2_memop[op->value.id] = op;
1247
}  /* add_memop */
1248
1249
1250
1251
1252
1253
1254

/**
 * Add the value of a memop to the avail_out set.
 *
 * @param bl  the block
 * @param op  the memory op
 */
1255
1256
static void add_memop_avail(block_t *bl, memop_t *op)
{
1257
1258
	rbitset_set(bl->avail_out, op->value.id);
	bl->id_2_memop_avail[op->value.id] = op;
1259
}  /* add_memop_avail */
1260

Michael Beck's avatar
Michael Beck committed
1261
1262
1263
/**
 * Check, if we can convert a value of one mode to another mode
 * without changing the representation of bits.
1264
1265
1266
 *
 * @param from  the original mode
 * @param to    the destination mode
Michael Beck's avatar
Michael Beck committed
1267
 */
1268
1269
static int can_convert_to(const ir_mode *from, const ir_mode *to)
{
Michael Beck's avatar
Michael Beck committed
1270
1271
1272
1273
1274
	if (get_mode_arithmetic(from) == irma_twos_complement &&
	    get_mode_arithmetic(to) == irma_twos_complement &&
	    get_mode_size_bits(from) == get_mode_size_bits(to))
		return 1;
	return 0;
1275
}  /* can_convert_to */
Michael Beck's avatar
Michael Beck committed
1276

1277
/**
1278
1279
1280
1281
1282
1283
1284
 * Add a Conv to the requested mode if needed.
 *
 * @param irn   the IR-node to convert
 * @param mode  the destination mode
 *
 * @return the possible converted node or NULL
 *         if the conversion is not possible
1285
 */
1286
1287
static ir_node *conv_to(ir_node *irn, ir_mode *mode)
{
1288
1289
1290
	ir_mode *other = get_irn_mode(irn);
	if (other != mode) {
		/* different modes: check if conversion is possible without changing the bits */
Michael Beck's avatar
Michael Beck committed
1291
		if (can_convert_to(other, mode)) {
1292
			ir_node *block = get_nodes_block(irn);
1293
			return new_r_Conv(block, irn, mode);
1294
		}
1295
1296
		/* otherwise not possible ... yet */
		return NULL;
1297
	}
1298
	return irn;
1299
}  /* conv_to */
1300

1301
1302
1303
1304
1305
1306
/**
 * Update the address of an value if this address was a load result
 * and the load is killed now.
 *
 * @param value  the value whose address is updated
 */
1307
1308
static void update_address(value_t *value)
{
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
	if (is_Proj(value->address)) {
		ir_node *load = get_Proj_pred(value->address);

		if (is_Load(load)) {
			const memop_t *op = get_irn_memop(load);

			if (op->flags & FLAG_KILLED_NODE)
				value->address = op->replace;
		}
	}
1319
}  /* update_address */
1320

1321
/**
Michael Beck's avatar
Michael Beck committed
1322
1323
 * Do forward dataflow analysis on the given block and calculate the
 * GEN and KILL in the current (avail) set.
1324
1325
1326
 *
 * @param bl  the block
 */
1327
1328
static void calc_gen_kill_avail(block_t *bl)
{
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
	memop_t *op;
	ir_node *def;

	for (op = bl->memop_forward; op != NULL; op = op->next) {
		switch (get_irn_opcode(op->node)) {
		case iro_Phi:
			/* meet */
			break;
		case iro_Sync:
			/* join */
			break;
		case iro_Load:
			if (! (op->flags & (FLAG_KILLED_NODE|FLAG_IGNORE))) {
				/* do we have this already? */
1343
1344
1345
1346
				memop_t *other;

				update_address(&op->value);
				other = find_address(&op->value);
1347
1348
				if (other != NULL && other != op) {
					def = conv_to(other->value.value, op->value.mode);
1349