Investigating PR target/86891 revealed a number of issues with the way the...
authorRichard Earnshaw <rearnsha@arm.com>
Mon, 7 Jan 2019 14:49:00 +0000 (14:49 +0000)
committerRichard Earnshaw <rearnsha@gcc.gnu.org>
Mon, 7 Jan 2019 14:49:00 +0000 (14:49 +0000)
commita58fe3c5ca1f0101c4af7f0c5b860cc4d49cd4cb
treecb7d7c9f5f6a7f4146e8ecbee86803c85cbe2496
parentdf35e0bde1f245e8cd49c29cb4de9747257151cd
Investigating PR target/86891 revealed a number of issues with the way the...

Investigating PR target/86891 revealed a number of issues with the way
the AArch64 backend was handing overflow detection patterns.  Firstly,
expansion for signed and unsigned types is not the same as in one form
the overflow is detected via the C flag and in the other it is done
via the V flag in the PSR.  Secondly, particular care has to be taken
when describing overflow of signed types: the comparison has to be
performed conceptually on a value that cannot overflow and compared to
a value that might have overflowed.

It became apparent that some of the patterns were simply unmatchable
(they collapse to NEG in the RTL rather than subtracting from zero)
and a number of patterns were overly restrictive in terms of the
immediate constants that they supported.  I've tried to address all of
these issues as well.

gcc:

PR target/86891
* config/aarch64/aarch64.c (aarch64_expand_subvti): New parameter
unsigned_p.  Handle signed and unsigned overflow correction as
required.
* config/aarch64/aarch64-protos.h (aarch64_expand_subvti): Update
prototype.
* config/aarch64/aarch64.md (addv<mode>4): Use aarch64_plus_operand
for operand 2.
(add<mode>3_compareV_imm): Make this callable for expanding.
(subv<GPI:mode>4): Use register_operand for operand 1.  Use
aarch64_plus_operand for operand 2.
(subv<GPI:mode>_insn): New insn pattern.
(subv<GPI:mode>_imm): Likewise.
(negv<GPI:mode>3): New expand pattern.
(negv<GPI:mode>_insn): New insn pattern.
(negv<GPI:mode>_cmp_only): Likewise.
(cmpv<GPI:mode>_insn): Likewise.
(subvti4): Use register_operand for operand 1.  Update call to
aarch64_expand_subvti.
(usubvti4): Likewise.
(negvti3): New expand pattern.
(negdi_carryout): New insn pattern.
(negvdi_carryinV): New insn pattern.
(sub<mode3>_compare1_imm): Delete named insn pattern, make anonymous
version the named version.
(peepholes to convert to sub<mode3>_compare1_imm): Adjust order of
operands.
(usub<GPI:mode>3_carryinC, usub<GPI:mode>3_carryinC_z1): New insn
patterns.
(usub<GPI:mode>3_carryinC_z2, usub<GPI:mode>3_carryinC): New insn
patterns.
(sub<mode>3_carryinCV, sub<mode>3_carryinCV_z1_z2): Delete.
(sub<mode>3_carryinCV_z1, sub<mode>3_carryinCV_z2): Delete.
(sub<mode>3_carryinCV): Delete.
(sub<GPI:mode>3_carryinV): New expand pattern.
sub<mode>3_carryinV, sub<mode>3_carryinV_z2): New insn patterns.

testsuite:

* gcc.target/aarch64/subs_compare_2.c: Make '#' immediate prefix
optional in scan pattern.

From-SVN: r267650
gcc/ChangeLog
gcc/config/aarch64/aarch64-protos.h
gcc/config/aarch64/aarch64.c
gcc/config/aarch64/aarch64.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/aarch64/subs_compare_2.c