-//TODO: - iff PERM_CYCLE && do_copy -> determine free temp reg and insert copy to/from it before/after
-// the copy cascade (this reduces the cycle into a chain)
-
- /* build copy/swap nodes from back to front */
- for (i = cycle->n_elems - 2; i >= 0; i--) {
- arg1 = get_node_for_register(pairs, n, cycle->elems[i], 0);
- arg2 = get_node_for_register(pairs, n, cycle->elems[i + 1], 0);
-
- res1 = get_node_for_register(pairs, n, cycle->elems[i], 1);
- res2 = get_node_for_register(pairs, n, cycle->elems[i + 1], 1);
- /*
- If we have a cycle and don't copy: we need to create exchange nodes
- NOTE: An exchange node is a perm node with 2 INs and 2 OUTs
- IN_1 = in node with register i
- IN_2 = in node with register i + 1
- OUT_1 = out node with register i + 1
- OUT_2 = out node with register i
- */
- if (cycle->type == PERM_CYCLE && !do_copy) {
- in[0] = arg1;
- in[1] = arg2;
-
- /* At this point we have to handle the following problem: */
- /* */
- /* If we have a cycle with more than two elements, then */
- /* this could correspond to the following Perm node: */
- /* */
- /* +----+ +----+ +----+ */
- /* | r1 | | r2 | | r3 | */
- /* +-+--+ +-+--+ +--+-+ */
- /* | | | */
- /* | | | */
- /* +-+--------+---------+-+ */
- /* | Perm | */
- /* +-+--------+---------+-+ */
- /* | | | */
- /* | | | */
- /* +-+--+ +-+--+ +--+-+ */
- /* |Proj| |Proj| |Proj| */
- /* | r2 | | r3 | | r1 | */
- /* +----+ +----+ +----+ */
- /* */
- /* This node is about to be split up into two 2x Perm's */
- /* for which we need 4 Proj's and the one additional Proj */
- /* of the first Perm has to be one IN of the second. So in */
- /* general we need to create one additional Proj for each */
- /* "middle" Perm and set this to one in node of the successor */
- /* Perm. */
-
- DBG((mod, LEVEL_1, "%+F creating exchange node (%+F, %s) and (%+F, %s) with\n",
- irn, arg1, cycle->elems[i]->name, arg2, cycle->elems[i + 1]->name));
- DBG((mod, LEVEL_1, "%+F (%+F, %s) and (%+F, %s)\n",
- irn, res1, cycle->elems[i]->name, res2, cycle->elems[i + 1]->name));
-
- cpyxchg = be_new_Perm(reg_class, irg, block, 2, in);
- n_ops++;
-
- if (i > 0) {
- /* cycle is not done yet */
- int pidx = get_pairidx_for_regidx(pairs, n, cycle->elems[i]->index, 0);
-
- /* create intermediate proj */
- res1 = new_r_Proj(irg, block, cpyxchg, get_irn_mode(res1), 0);
-
- /* set as in for next Perm */
- pairs[pidx].in_node = res1;
- }
- else {
-#ifdef SCHEDULE_PROJS
- sched_remove(res1);
-#endif
- }
+ if (cycle.type == PERM_CYCLE && arity == 2) {
+ /* We don't need to do anything if we have a Perm with two elements
+ * which represents a cycle, because those nodes already represent
+ * exchange nodes */
+ keep_perm = 1;
+ } else {
+ /* TODO: - iff PERM_CYCLE && do_copy -> determine free temp reg and
+ * insert copy to/from it before/after the copy cascade (this
+ * reduces the cycle into a chain) */
+
+ /* build copy/swap nodes from back to front */
+ for (i = cycle.n_elems - 2; i >= 0; i--) {
+ ir_node *arg1 = get_node_for_in_register(pairs, n, cycle.elems[i]);
+ ir_node *arg2 = get_node_for_in_register(pairs, n, cycle.elems[i + 1]);
+
+ ir_node *res1 = get_node_for_out_register(pairs, n, cycle.elems[i]);
+ ir_node *res2 = get_node_for_out_register(pairs, n, cycle.elems[i + 1]);
+ /* If we have a cycle and don't copy: we need to create exchange
+ * nodes
+ * NOTE: An exchange node is a perm node with 2 INs and 2 OUTs
+ * IN_1 = in node with register i
+ * IN_2 = in node with register i + 1
+ * OUT_1 = out node with register i + 1
+ * OUT_2 = out node with register i */
+ if (cycle.type == PERM_CYCLE && !do_copy) {
+ ir_node *in[2];
+ ir_node *cpyxchg;
+
+ in[0] = arg1;
+ in[1] = arg2;
+
+ /* At this point we have to handle the following problem:
+ *
+ * If we have a cycle with more than two elements, then this
+ * could correspond to the following Perm node:
+ *
+ * +----+ +----+ +----+
+ * | r1 | | r2 | | r3 |
+ * +-+--+ +-+--+ +--+-+
+ * | | |
+ * | | |
+ * +-+--------+---------+-+
+ * | Perm |
+ * +-+--------+---------+-+
+ * | | |
+ * | | |
+ * +-+--+ +-+--+ +--+-+
+ * |Proj| |Proj| |Proj|
+ * | r2 | | r3 | | r1 |
+ * +----+ +----+ +----+
+ *
+ * This node is about to be split up into two 2x Perm's for
+ * which we need 4 Proj's and the one additional Proj of the
+ * first Perm has to be one IN of the second. So in general
+ * we need to create one additional Proj for each "middle"
+ * Perm and set this to one in node of the successor Perm. */
+
+ DBG((dbg, LEVEL_1, "%+F creating exchange node (%+F, %s) and (%+F, %s) with\n",
+ irn, arg1, cycle.elems[i]->name, arg2, cycle.elems[i + 1]->name));
+ DBG((dbg, LEVEL_1, "%+F (%+F, %s) and (%+F, %s)\n",
+ irn, res1, cycle.elems[i]->name, res2, cycle.elems[i + 1]->name));
+
+ cpyxchg = be_new_Perm(reg_class, irg, block, 2, in);
+
+ if (i > 0) {
+ /* cycle is not done yet */
+ int pidx = get_pairidx_for_in_regidx(pairs, n, cycle.elems[i]->index);
+
+ /* create intermediate proj */
+ res1 = new_r_Proj(irg, block, cpyxchg, get_irn_mode(res1), 0);
+
+ /* set as in for next Perm */
+ pairs[pidx].in_node = res1;
+ }