Force the selection operand of a GIMPLE COND_EXPR to be a register
authorRichard Biener <rguenther@suse.de>
Mon, 11 Apr 2022 11:36:53 +0000 (13:36 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 23 May 2022 09:30:39 +0000 (11:30 +0200)
commit68e0063397ba820e71adc220b2da0581dce29ffa
tree171b9d384db6af4abe9509eadbfd1fc950bf0e15
parent49d1a2f91325fa8cc011149e27e5093a988b3a49
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  <rguenther@suse.de>

* 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.
21 files changed:
gcc/gimple-expr.cc
gcc/gimple-fold.cc
gcc/gimple-loop-interchange.cc
gcc/gimple-range-gori.cc
gcc/gimplify.cc
gcc/omp-expand.cc
gcc/testsuite/gcc.dg/gimplefe-27.c
gcc/testsuite/gcc.dg/gimplefe-45.c
gcc/testsuite/gcc.dg/pr101145-2.c
gcc/testsuite/gcc.dg/pr98211.c
gcc/testsuite/gcc.dg/torture/pr89595.c
gcc/testsuite/gcc.dg/tree-ssa/divide-7.c
gcc/testsuite/gcc.dg/tree-ssa/ssa-lim-12.c
gcc/tree-cfg.cc
gcc/tree-if-conv.cc
gcc/tree-ssa-forwprop.cc
gcc/tree-ssa-loop-im.cc
gcc/tree-vect-generic.cc
gcc/tree-vect-loop.cc
gcc/tree-vect-patterns.cc
gcc/vr-values.cc