https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86891

--- Comment #8 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
Author: rearnsha
Date: Mon Jan  7 14:49:00 2019
New Revision: 267650

URL: https://gcc.gnu.org/viewcvs?rev=267650&root=gcc&view=rev
Log:
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.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/aarch64/aarch64-protos.h
    trunk/gcc/config/aarch64/aarch64.c
    trunk/gcc/config/aarch64/aarch64.md
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.target/aarch64/subs_compare_2.c

Reply via email to