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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:2af6dd77ea742d4ee911f466878624972929508a

commit r12-3312-g2af6dd77ea742d4ee911f466878624972929508a
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Thu Sep 2 11:25:07 2021 +0200

    match.pd: Demote IFN_{ADD,SUB,MUL}_OVERFLOW operands [PR99591]

    The overflow builtins work on infinite precision integers and then convert
    to the result type's precision, so any argument promotions are useless.
    The expand_arith_overflow expansion is able to demote the arguments itself
    through get_range_pos_neg and get_min_precision calls and if needed promote
    to whatever mode it decides to perform the operations in, but if there are
    any promotions it demoted, those are already expanded.  Normally combine
    would remove the useless sign or zero extensions when it sees the result
    of those is only used in a lowpart subreg, but typically those lowpart
    subregs appear multiple times in the pattern so that they describe properly
    the overflow behavior and combine gives up, so we end up with e.g.
            movswl  %si, %esi
            movswl  %di, %edi
            imulw   %si, %di
            seto    %al
    where both movswl insns are useless.

    The following patch fixes it by demoting operands of the ifns (only gets
    rid of integral to integral conversions that increase precision).
    While IFN_{ADD,MUL}_OVERFLOW are commutative and just one simplify would be
    enough, IFN_SUB_OVERFLOW is not, therefore two simplifications.

    2021-09-02  Jakub Jelinek  <ja...@redhat.com>

            PR tree-optimization/99591
            * match.pd: Demote operands of IFN_{ADD,SUB,MUL}_OVERFLOW if they
            were promoted.

            * gcc.target/i386/pr99591.c: New test.
            * gcc.target/i386/pr97950.c: Match or reject setb or jn?b
instructions
            together with seta or jn?a.

Reply via email to