[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] ifcvt: cleanup if_info->cond usage in noce_try_cond_zero_arith
Jeff Law
law@gcc.gnu.org
Sat Jan 17 07:28:32 GMT 2026
https://gcc.gnu.org/g:64e358ca8928a7608c6bf880722ad4f10f81c1d5
commit 64e358ca8928a7608c6bf880722ad4f10f81c1d5
Author: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
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 <andrew.pinski@oss.qualcomm.com>
(cherry picked from commit 594f2cbf30f0a36cd7891ec915abf4de08630e49)
Diff:
---
gcc/ifcvt.cc | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc
index e305e3b4c575..1f6538beb791 100644
--- a/gcc/ifcvt.cc
+++ b/gcc/ifcvt.cc
@@ -3145,10 +3145,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
@@ -3169,9 +3169,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. */
@@ -3201,8 +3206,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)
@@ -3241,8 +3246,6 @@ end_seq_n_fail:
end_sequence ();
fail:
- if (reverse)
- std::swap (if_info->cond, if_info->rev_cond);
return false;
}
More information about the Gcc-cvs
mailing list