From 68e0063397ba820e71adc220b2da0581dce29ffa Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 11 Apr 2022 13:36:53 +0200 Subject: Force the selection operand of a GIMPLE COND_EXPR to be a register This goes away with the selection operand allowed to be a GENERIC tcc_comparison tree. It keeps those for vectorizer pattern recog, those are short lived and removing this instance is a bigger task. The patch doesn't yet remove dead code and functionality, that's left for a followup. Instead the patch makes sure to produce valid GIMPLE IL and continue to optimize COND_EXPRs where the previous IL allowed and the new IL showed regressions in the testsuite. 2022-05-16 Richard Biener * gimple-expr.cc (is_gimple_condexpr): Equate to is_gimple_val. * gimplify.cc (gimplify_pure_cond_expr): Gimplify the condition as is_gimple_val. * gimple-fold.cc (valid_gimple_rhs_p): Simplify. * tree-cfg.cc (verify_gimple_assign_ternary): Likewise. * gimple-loop-interchange.cc (loop_cand::undo_simple_reduction): Build the condition of the COND_EXPR separately. * tree-ssa-loop-im.cc (move_computations_worker): Likewise. * tree-vect-generic.cc (expand_vector_condition): Likewise. * tree-vect-loop.cc (vect_create_epilog_for_reduction): Likewise. * vr-values.cc (simplify_using_ranges::simplify): Likewise. * tree-vect-patterns.cc: Add comment indicating we are building invalid COND_EXPRs and why. * omp-expand.cc (expand_omp_simd): Gimplify the condition to the COND_EXPR separately. (expand_omp_atomic_cas): Note part that should be unreachable now. * tree-ssa-forwprop.cc (forward_propagate_into_cond): Adjust condition for valid replacements. * tree-if-conv.cc (predicate_bbs): Simulate previous re-folding of the condition in folded COND_EXPRs which is necessary because of unfolded GIMPLE_CONDs in the IL as in for example gcc.dg/fold-bopcond-1.c. * gimple-range-gori.cc (gori_compute::condexpr_adjust): Handle that the comparison is now in the def stmt of the select operand. Required by gcc.dg/pr104526.c. * gcc.dg/gimplefe-27.c: Adjust. * gcc.dg/gimplefe-45.c: Likewise. * gcc.dg/pr101145-2.c: Likewise. * gcc.dg/pr98211.c: Likewise. * gcc.dg/torture/pr89595.c: Likewise. * gcc.dg/tree-ssa/divide-7.c: Likewise. * gcc.dg/tree-ssa/ssa-lim-12.c: Likewise. --- gcc/gimple-loop-interchange.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gcc/gimple-loop-interchange.cc') diff --git a/gcc/gimple-loop-interchange.cc b/gcc/gimple-loop-interchange.cc index 53adc02..d5d690b 100644 --- a/gcc/gimple-loop-interchange.cc +++ b/gcc/gimple-loop-interchange.cc @@ -897,7 +897,9 @@ loop_cand::undo_simple_reduction (reduction_p re, bitmap dce_seeds) /* Init new_var to MEM_REF or CONST depending on if it is the first iteration. */ induction_p iv = m_inductions[0]; - cond = fold_build2 (NE_EXPR, boolean_type_node, iv->var, iv->init_val); + cond = make_ssa_name (boolean_type_node); + stmt = gimple_build_assign (cond, NE_EXPR, iv->var, iv->init_val); + gimple_seq_add_stmt_without_update (&stmts, stmt); new_var = copy_ssa_name (re->var); stmt = gimple_build_assign (new_var, COND_EXPR, cond, tmp, re->init); gimple_seq_add_stmt_without_update (&stmts, stmt); -- cgit v1.1