On 01/08/2016 02:11 PM, Kyrill Tkachov wrote:
How's this?
Hmm. Almost there, but...
- if (then_bb && else_bb && !a_simple && !b_simple - && (!bbs_ok_for_cmove_arith (then_bb, else_bb) - || !bbs_ok_for_cmove_arith (else_bb, then_bb))) + rtx orig_x = x; + if (then_bb && else_bb) + { + orig_x = SET_DEST (single_set (insn_a)); + gcc_assert (rtx_equal_p (orig_x, SET_DEST (single_set (insn_b)))); + } + + if (then_bb && else_bb + && (!bbs_ok_for_cmove_arith (then_bb, else_bb, orig_x) + || !bbs_ok_for_cmove_arith (else_bb, then_bb, orig_x))) return FALSE;
This can be condensed to a single if statement (not repeating the then_bb && else_bb test), and orig_x can then be declared locally inside it.
The remaining question is whether it's safe to call single_set in this way. I thought it was only guaranteed to be safe if then_simple and else_simple. I had assumed that orig_x was available in this function but I now see that it's actually part of noce_process_if_block. I think it might be best to extend the if_info structure to also have an orig_x field. With that, I think we can even skip this particular assert (keeping the one in bbs_ok_for_cmove_arith however).
Bernd