- else {
- if (out_op == op_Cmp && !is_loop_invariant(out, loop_head)){
- cmp_pred_bl = get_irn_out(out, 0);
- cmp_pred_bl = get_irn_out(cmp_pred_bl, 0);
- cond_succ_true = get_irn_out(cmp_pred_bl, 1);
- cond_succ_false = get_irn_out(cmp_pred_bl, 0);
- if(is_loop_invariant(get_irn_out(cond_succ_false, 0), loop_head) ||
- is_loop_invariant(get_irn_out(cond_succ_true, 0), loop_head)){
- if (get_Cmp_left(out) == info->itervar_phi)
- cmp_const = get_Cmp_right(out);
- else
- cmp_const = get_Cmp_left(out);
- } else
- continue;
- if (info->cmp == NULL) {
- info->cmp = out;
- info->cmp_const = cmp_const;
- } else {
- info->cmp = NULL;
- return NULL;
- }
+ else if (out_op == op_Cmp && !is_loop_invariant(out, loop_head)) {
+ /* a Cmp can have more than one successor therefore we need this loop.*/
+ for (q = get_irn_n_outs(out) - 1; q >= 0; --q) {
+ ir_node *proj = get_irn_out(out, q);
+
+ for (r = get_irn_n_outs(proj) -1; r >= 0; --r) {
+ cmp_pred_bl = get_irn_out(proj, r);
+
+ /* The wanted Cmp must be followed by a Cond successor
+ not by a Mux. */
+ if (get_irn_op(cmp_pred_bl) != op_Cond)
+ continue;
+
+ /* the binary Cond should have two successors */
+ if (get_irn_n_outs(cmp_pred_bl) != 2)
+ continue;
+
+ cond_succ_0 = get_irn_out(cmp_pred_bl, 0);
+ cond_succ_1 = get_irn_out(cmp_pred_bl, 1);
+
+ if (is_loop_invariant(get_irn_out(cond_succ_1, 0), loop_head) ||
+ is_loop_invariant(get_irn_out(cond_succ_0, 0), loop_head)) {
+ if (get_Cmp_left(out) == info->itervar_phi)
+ cmp_const = get_Cmp_right(out);
+ else
+ cmp_const = get_Cmp_left(out);
+ } else
+ continue;
+ if (info->cmp == NULL) {
+ /* A cmp is found.*/
+ info->cmp = out;
+ info->cmp_const = cmp_const;
+ }
+ else {
+ /* We have more then one cmp with our requests, that mean cmp isn't found */
+ info->cmp = NULL;
+ return NULL;
+ }
+ }