optabs: Don't create pseudos in prepare_cmp_insn when not allowed [PR102478]
authorJakub Jelinek <jakub@redhat.com>
Fri, 21 Jan 2022 10:16:50 +0000 (11:16 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 21 Jan 2022 10:16:50 +0000 (11:16 +0100)
commitc2d9159717b474f9c06dde4d32b48b87164deb50
treee5a8fa24b2029bc83a4bb9dce2653805e0b4d21b
parent6f45deb2aed804b185e7dabd2392bfbe14e9bb57
optabs: Don't create pseudos in prepare_cmp_insn when not allowed [PR102478]

cond traps can be created during ce3 after reload (and e.g. PR103028
recently fixed some ce3 cond trap related bug, so I think often that
works fine and we shouldn't disable cond traps after RA altogether),
but it calls prepare_cmp_insn.  This function can fail, so I don't
see why we couldn't make it work after RA (in most cases it already
just works).  The first hunk is just an optimization which doesn't
make sense after RA, so I've guarded it with can_create_pseudo_p.
The second hunk is just a theoretical case, I don't have a testcase for it.
prepare_cmp_insn has some other spots that can create pseudos, like when
both operands have VOIDmode, or when it is BLKmode comparison, or
not OPTAB_DIRECT, but I think none of that applies to ce3, we punt on
BLKmode earlier, use OPTAB_DIRECT and shouldn't be comparing two
VOIDmode CONST_INTs.

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

PR rtl-optimization/102478
* optabs.cc (prepare_cmp_insn): If !can_create_pseudo_p (), don't
force_reg constants and for -fnon-call-exceptions fail if copy_to_reg
would be needed.

* gcc.dg/pr102478.c: New test.
gcc/optabs.cc
gcc/testsuite/gcc.dg/pr102478.c [new file with mode: 0644]