This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/83687] [6/7/8 Regression] ARM NEON invalid optimisation for vabd/vabdl


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

--- Comment #3 from ktkachov at gcc dot gnu.org ---
Author: ktkachov
Date: Mon Jan 15 11:56:03 2018
New Revision: 256696

URL: https://gcc.gnu.org/viewcvs?rev=256696&root=gcc&view=rev
Log:
[arm] PR target/83687: Fix invalid combination of VSUB + VABS into VABD

In this wrong-code bug we combine a VSUB.I8 and a VABS.S8
into a VABD.S8 instruction . This combination is not valid
for integer operands because in the VABD instruction the semantics
are that the difference is computed in notionally infinite precision
and the absolute difference is computed on that, whereas for a
VSUB.I8 + VABS.S8 sequence the VSUB operation will perform any
wrapping that's needed for the 8-bit signed type before the VABS
gets its hands on it.

This leads to the wrong-code in the PR where the expected
sequence from the intrinsics:
VSUB + VABS of two vectors {-100, -100, -100...}, {100, 100, 100...}
gives a result of {56, 56, 56...} (-100 - 100)

but GCC optimises it into a single
VABD of {-100, -100, -100...}, {100, 100, 100...}
which produces a result of {200, 200, 200...}

The transformation is still valid for floating-point operands,
which is why it was added in the first place I believe (r178817)
but this patch disables it for integer operands.
The HFmode variants though only exist for TARGET_NEON_FP16INST, so
this patch adds the appropriate guards to the new mode iterator

Bootstrapped and tested on arm-none-linux-gnueabihf.

        PR target/83687
        * config/arm/iterators.md (VF): New mode iterator.
        * config/arm/neon.md (neon_vabd<mode>_2): Use the above.
        Remove integer-related logic from pattern.
        (neon_vabd<mode>_3): Likewise.

        * gcc.target/arm/neon-combine-sub-abs-into-vabd.c: Delete integer
        tests.
        * gcc.target/arm/pr83687.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/arm/pr83687.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/arm/iterators.md
    trunk/gcc/config/arm/neon.md
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.target/arm/neon-combine-sub-abs-into-vabd.c

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]