https://gcc.gnu.org/g:594f2cbf30f0a36cd7891ec915abf4de08630e49
commit r16-6435-g594f2cbf30f0a36cd7891ec915abf4de08630e49 Author: Andrew Pinski <[email protected]> Date: Sun Dec 28 12:39:13 2025 -0800 ifcvt: cleanup if_info->cond usage in noce_try_cond_zero_arith Since r16-6332-g2a84a753afcf37, if_info->cond is not used indirectly any more for creating the conditional. So this patch stops doing the swap and fixes up so the case where if_info->rev_cond might be null. gcc/ChangeLog: * ifcvt.cc (noce_try_cond_zero_arith): Don't swap if_info->cond but use it directly with if_info->rev_cond. Signed-off-by: Andrew Pinski <[email protected]> Diff: --- gcc/ifcvt.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc index 75d959f652c5..562775165a2f 100644 --- a/gcc/ifcvt.cc +++ b/gcc/ifcvt.cc @@ -3142,10 +3142,10 @@ noce_try_cond_zero_arith (struct noce_if_info *if_info) { rtx target, a, b, a_op0, a_op1; rtx cond = if_info->cond; + rtx_code code = GET_CODE (cond); rtx_insn *seq; rtx_code op; machine_mode mode = GET_MODE (if_info->x); - bool reverse = false; /* Scalar integral modes are only supported here. Could support scalar floating point but that @@ -3166,9 +3166,14 @@ noce_try_cond_zero_arith (struct noce_if_info *if_info) /* Canonicalize x = y : (y op z) to x = (y op z) : y. */ if (REG_P (a) && noce_cond_zero_binary_op_supported (b)) { - std::swap (if_info->cond, if_info->rev_cond); + if (if_info->rev_cond) + { + cond = if_info->rev_cond; + code = GET_CODE (cond); + } + else + code = reversed_comparison_code (cond, if_info->jump); std::swap (a, b); - reverse = true; } /* Check if x = (y op z) : y is supported by czero based ifcvt. */ @@ -3198,8 +3203,8 @@ noce_try_cond_zero_arith (struct noce_if_info *if_info) target = gen_reg_rtx (GET_MODE (XEXP (a, op != AND))); /* AND requires !cond, instead we swap ops around. */ - target = noce_emit_cmove (if_info, target, GET_CODE (if_info->cond), - XEXP (if_info->cond, 0), XEXP (if_info->cond, 1), + target = noce_emit_cmove (if_info, target, code, + XEXP (cond, 0), XEXP (cond, 1), op != AND ? XEXP (a, 1) : const0_rtx, op != AND ? const0_rtx : XEXP (a, 0)); if (!target) @@ -3238,8 +3243,6 @@ end_seq_n_fail: end_sequence (); fail: - if (reverse) - std::swap (if_info->cond, if_info->rev_cond); return false; }
