]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ifcvt: cleanup if_info->cond usage in noce_try_cond_zero_arith
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Sun, 28 Dec 2025 20:39:13 +0000 (12:39 -0800)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Mon, 29 Dec 2025 18:27:40 +0000 (10:27 -0800)
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 <andrew.pinski@oss.qualcomm.com>
gcc/ifcvt.cc

index 75d959f652c58ef85d00958123d9e48203f66e90..562775165a2f8cc61d50a4a864f94da228c201d6 100644 (file)
@@ -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;
 }