* Make the Perm, recompute liveness and re-scan the insn since the
* in operands are now the Projs of the Perm.
*/
- perm = insert_Perm_after(env->irg, env->cls, sched_prev(insn->irn));
+ perm = insert_Perm_before(env->irg, env->cls, insn->irn);
- /* Registers are propagated by insert_Perm_after(). Clean them here! */
+ /* Registers are propagated by insert_Perm_before(). Clean them here! */
if (perm == NULL)
return NULL;
*/
-ir_node *insert_Perm_after(ir_graph *irg, const arch_register_class_t *cls,
+ir_node *insert_Perm_before(ir_graph *irg, const arch_register_class_t *cls,
ir_node *pos)
{
be_lv_t *lv = be_get_irg_liveness(irg);
- ir_node *bl = is_Block(pos) ? pos : get_nodes_block(pos);
ir_nodeset_t live;
ir_node *perm, **nodes;
size_t i, n;
- DBG((dbg, LEVEL_1, "Insert Perm after: %+F\n", pos));
+ DBG((dbg, LEVEL_1, "Insert Perm before: %+F\n", pos));
ir_nodeset_init(&live);
- be_liveness_nodes_live_at(lv, cls, pos, &live);
+ be_liveness_nodes_live_at(lv, cls, sched_prev(pos), &live);
n = ir_nodeset_size(&live);
if (n == 0) {
/* make the input order deterministic */
qsort(nodes, n, sizeof(nodes[0]), cmp_node_nr);
+ ir_node *const bl = get_nodes_block(pos);
perm = be_new_Perm(cls, bl, n, nodes);
- sched_add_after(pos, perm);
+ sched_add_before(pos, perm);
free(nodes);
for (i = 0; i < n; ++i) {
* Insert a Perm which permutes all (non-ignore) live values of a given register class
* after a certain instruction.
* @param lv Liveness Information.
- * @param irn The node to insert the Perm after.
- * @return The Perm or NULL if nothing was live before @p irn.
+ * @param irn The node to insert the Perm before.
+ * @return The Perm or NULL if nothing was live after @p irn.
*/
-ir_node *insert_Perm_after(ir_graph *irg, const arch_register_class_t *cls,
+ir_node *insert_Perm_before(ir_graph *irg, const arch_register_class_t *cls,
ir_node *irn);
/**