aarch64: Fix {ash[lr],lshr}<mode>3 expanders [PR94488]
authorJakub Jelinek <jakub@redhat.com>
Tue, 7 Apr 2020 08:01:16 +0000 (10:01 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 7 Apr 2020 08:01:16 +0000 (10:01 +0200)
commit7a6588fe65432c0f1a8b5fdefba81700ebf88711
treed29ec8d82d9f8f99505d44ab2333b5f1ae085f34
parent30d26118f96fa542ee078834bc3cb4eef6730451
aarch64: Fix {ash[lr],lshr}<mode>3 expanders [PR94488]

The following testcase ICEs on aarch64 apparently since the introduction of
the aarch64 port.  The reason is that the {ashl,ashr,lshr}<mode>3 expanders
completely unnecessarily FAIL; if operands[2] is something other than
a CONST_INT or REG or MEM and the middle-end code can't cope with the
pattern giving up in these cases.  All the expanders use general_operand
predicate for the shift amount operand, but then have just a special case
for CONST_INT (if in-bound, emit an immediate shift, otherwise force into
REG), or MEM (force into REG), or REG (that is the case it handles).
In the testcase, operands[2] is a lowpart SUBREG of a REG, which is valid
general_operand.
I don't see any reason what is magic about MEMs that it should be forced
into REG and others like SUBREGs that it shouldn't, there isn't even a
reason to check for !REG_P because force_reg will do nothing if the operand
is already a REG, and otherwise can handle general_operand just fine.

2020-04-07  Jakub Jelinek  <jakub@redhat.com>

PR target/94488
* config/aarch64/aarch64-simd.md (ashl<mode>3, lshr<mode>3,
ashr<mode>3): Force operands[2] into reg whenever it is not CONST_INT.
Assume it is a REG after that instead of testing it and doing FAIL
otherwise.  Formatting fix.

* gcc.c-torture/compile/pr94488.c: New test.
gcc/config/aarch64/aarch64-simd.md
gcc/testsuite/gcc.c-torture/compile/pr94488.c [new file with mode: 0644]