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 tree-optimization/88064] [9 Regression] Incorrect vectorizer over_widening pattern handling


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

--- Comment #3 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
Author: rsandifo
Date: Wed Dec  5 15:53:03 2018
New Revision: 266829

URL: https://gcc.gnu.org/viewcvs?rev=266829&root=gcc&view=rev
Log:
Use unsigned arithmetic for demoted vector plus/minus/mult (PR 88064)

As Jakub pointed out, if we narrow a plus, minus or mult operation based
on the number of bits that consumers need, we have to convert a signed
operation to an unsigned one in order to avoid new undefined behaviour.
This patch does that and generalises vect_convert_input and
vect_recog_over_widening_pattern to cope with the extra casts.
(The changes to both functions are covered by existing tests.)

2018-12-03  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
        PR tree-optimization/88064
        * tree-vect-patterns.c (vect_convert_input): Convert the result of
        an existing cast if it has the right width but the wrong sign.
        Do not test the signedness of the required result when
        considering whether to split an existing cast; instead split to
        a type with the same signedness as the source of the cast, then
        convert it to the opposite signedness where necessary.
        (vect_recog_over_widening_pattern): Handle sign changes between
        the final PLUS_EXPR and the RSHIFT_EXPR.
        (vect_recog_average_pattern): Use an unsigned operation when
        truncating an addition, subtraction or multiplication.  Cast the
        result back to the "real" signedness before promoting.

gcc/testsuite/
        PR tree-optimization/88064
        * gcc.dg/vect/vect-over-widen-23.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/vect/vect-over-widen-23.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vect-patterns.c

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