i386: Fix up BFmode comparisons in conditional moves [PR107322]
authorJakub Jelinek <jakub@redhat.com>
Fri, 21 Oct 2022 16:34:37 +0000 (18:34 +0200)
committerJakub Jelinek <jakub@redhat.com>
Fri, 21 Oct 2022 16:34:37 +0000 (18:34 +0200)
commit5792208f5124f687376f25798668d105d7ddb270
tree6ed073bd73add054a0a4d55fc383ad20b6f17188
parent2cc41601d9a948e8d612a21c3b9a44ce0b977747
i386: Fix up BFmode comparisons in conditional moves [PR107322]

As the testcase shows, when cbranchbf4/cstorebf4 patterns are defined,
we can get ICEs for conditional moves.
The problem is that the generic conditional move expansion just calls
prepare_cmp_insn which just checks that such a cbranch<mode>4 exists
and returns directly such comparison and passes it down to the conditional
move optabs.
The following patch fixes it by punting if the comparisons aren't
ix86_fp_comparison_operator (to tell the generic code it should separately
compare) and to handle the promotion of BFmode comparison operands to
SFmode such that comparison is performed in SFmode.

2022-10-21  Jakub Jelinek  <jakub@redhat.com>

PR target/107322
* config/i386/i386-expand.cc (ix86_prepare_fp_compare_args): For
BFmode comparisons promote arguments to SFmode and recurse.
(ix86_expand_int_movcc, ix86_expand_fp_movcc): Return false early
if comparison operands are BFmode and operands[1] is not
ix86_fp_comparison_operator.

* gcc.target/i386/pr107322.c: New test.
gcc/config/i386/i386-expand.cc
gcc/testsuite/gcc.target/i386/pr107322.c [new file with mode: 0644]