]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/config/arc/arc.c
[ARC] Recognise add_n and sub_n in combine again
authorGraham Markall <graham.markall@embecosm.com>
Wed, 31 May 2017 13:15:33 +0000 (13:15 +0000)
committerAndrew Burgess <aburgess@gcc.gnu.org>
Wed, 31 May 2017 13:15:33 +0000 (14:15 +0100)
commit1e466f0496649db71f5e62881feea8ee59e09874
treec71ae273ffc9110bb43e8ae1947315de87e1e4f6
parent046a84762b7954d43d14aa8b7e48bf07b8117270
[ARC] Recognise add_n and sub_n in combine again

Since the combine pass canonicalises shift-add insns using plus and
ashift (as opposed to plus and mult which it previously used to do), it
no longer creates *add_n or *sub_n insns, as the patterns match plus and
mult only. The outcome of this is that some opportunities to generate
add{1,2,3} and sub{1,2,3} instructions are missed.

This change adds additional *add_n and *sub_n insns that match the
plus-ashift pattern. The original *add_n and *sub_n insns are still left
in, as they are sometimes generated later on by constant propagation.
The idea of adding these insns is modelled on the changes in:

  https://gcc.gnu.org/ml/gcc-patches/2015-05/msg01882.html

which addresses a similar issue for the PA target.

For the small test cases that are added, even if the combine pass misses
the opportunity to generate addN or subN, constant propagation manages
to do so, so the rtl of the combine pass is checked.

gcc/ChangeLog:

        * config/arc/arc.c (arc_print_operand): Handle constant operands.
        (arc_rtx_costs): Add costs for new patterns.
        * config/arc/arc.md: Additional *add_n and *sub_n patterns.
        * config/arc/predicates.md: Add _1_2_3_operand predicate.

gcc/testsuite/ChangeLog:

        * gcc.target/arc/add_n-combine.c: New test.
        * gcc.target/arc/sub_n-combine.c: New test.

From-SVN: r248735
gcc/ChangeLog
gcc/config/arc/arc.c
gcc/config/arc/arc.md
gcc/config/arc/predicates.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arc/add_n-combine.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arc/sub_n-combine.c [new file with mode: 0644]