]> git.ipfire.org Git - thirdparty/gcc.git/commit
middle-end/61747 - conditional move expansion and constants
authorRichard Biener <rguenther@suse.de>
Tue, 18 Jul 2023 11:19:11 +0000 (13:19 +0200)
committerRichard Biener <rguenther@suse.de>
Thu, 20 Jul 2023 07:50:43 +0000 (09:50 +0200)
commitceae1400cf24f329393e96dd9720b0391afe858d
tree44d0c07e2012d866c88c53d899fd464385ec77be
parentbb0da4542df887a530d5a75e08abf5cbb821fe6b
middle-end/61747 - conditional move expansion and constants

When expanding a COND_EXPR or a VEC_COND_EXPR the x86 backend for
example tries to match FP min/max instructions.  But this only
works when it can see the equality of the comparison and selected
operands.  This breaks in both prepare_cmp_insn and vector_compare_rtx
where the former forces expensive constants to a register and the
latter performs legitimization.  The patch below fixes this in
the caller preserving former equalities.

PR middle-end/61747
* internal-fn.cc (expand_vec_cond_optab_fn): When the
value operands are equal to the original comparison operands
preserve that equality by re-using the comparison expansion.
* optabs.cc (emit_conditional_move): When the value operands
are equal to the comparison operands and would be forced to
a register by prepare_cmp_insn do so earlier, preserving the
equality.

* g++.target/i386/pr61747.C: New testcase.
gcc/internal-fn.cc
gcc/optabs.cc
gcc/testsuite/g++.target/i386/pr61747.C [new file with mode: 0644]