]> gcc.gnu.org Git - gcc.git/commit
gcc: xtensa: reorder movsi_internal patterns for better code generation during LRA
authorMax Filippov <jcmvbkbc@gmail.com>
Thu, 14 Mar 2024 11:20:36 +0000 (04:20 -0700)
committerMax Filippov <jcmvbkbc@gmail.com>
Thu, 14 Mar 2024 17:27:08 +0000 (10:27 -0700)
commitbc5a9dab55d13f888a3cdd150c8cf5c2244f35e0
treed842ce601776c19c1f10ec60f7dda288c63fe806
parentf89cfdb2f2e9b4fe517b1e00511c4d70a7014cbc
gcc: xtensa: reorder movsi_internal patterns for better code generation during LRA

After switching to LRA xtensa backend generates the following code for
saving/loading registers:

    movi     a9, 0x190
    add      a9, a9, sp
    s32i.n   a3, a9, 0

instead of the shorter and more efficient

    s32i     a3, a9, 0x190

E.g. the following code can be used to reproduce it:

    int f1(int a, int b, int c, int d, int e, int f, int *p);
    int f2(int a, int b, int c, int d, int e, int f, int *p);
    int f3(int a, int b, int c, int d, int e, int f, int *p);

    int foo(int a, int b, int c, int d, int e, int f)
    {
        int g[100];
        return
            f1(a, b, c, d, e, f, g) +
            f2(a, b, c, d, e, f, g) +
            f3(a, b, c, d, e, f, g);
    }

This happens in the LRA pass because s32i.n and l32i.n are listed before
the s32i and l32i in the movsi_internal pattern and alternative
consideration loop stops early.

gcc/

* config/xtensa/xtensa.md (movsi_internal): Move l32i and s32i
patterns ahead of the l32i.n and s32i.n.
gcc/config/xtensa/xtensa.md
This page took 0.06856 seconds and 6 git commands to generate.