[AArch64] Improve register allocation of fma
commitd6e6e8b677a0dfec33b6adee2a7916c42cc38934
authorWilco Dijkstra <wdijkstr@arm.com>
Wed, 16 May 2018 14:33:16 +0000 (16 14:33 +0000)
committerWilco Dijkstra <wilco@gcc.gnu.org>
Wed, 16 May 2018 14:33:16 +0000 (16 14:33 +0000)
treebb8538b7e4e61a8407039d886ceb97ef55c88f26
parentdf0fc585b70b65a188de010f50cb90b0db3b9045
[AArch64] Improve register allocation of fma

This patch improves register allocation of fma by preferring to update the
accumulator register.  This is done by adding fma insns with operand 1 as the
accumulator.  The register allocator considers copy preferences only in operand
order, so if the first operand is dead, it has the highest chance of being
reused as the destination.  As a result code using fma often has a better
register allocation.  Performance of SPECFP2017 improves by over 0.5% on some
implementations, while it had no effect on other implementations.  Fma is more
readable too, in a simple example we now generate:

fmadd s16, s2, s1, s16
fmadd s7, s17, s16, s7
fmadd s6, s16, s7, s6
fmadd s5, s7, s6, s5

instead of:

fmadd s16, s16, s2, s1
fmadd s7, s7, s16, s6
fmadd s6, s6, s7, s5
fmadd s5, s5, s6, s4

    gcc/
* config/aarch64/aarch64.md (fma<mode>4): Change into expand pattern.
(fnma<mode>4): Likewise.
(fms<mode>4): Likewise.
(fnms<mode>4): Likewise.
(aarch64_fma<mode>4): Rename insn, reorder accumulator operand.
(aarch64_fnma<mode>4): Likewise.
(aarch64_fms<mode>4): Likewise.
(aarch64_fnms<mode>4): Likewise.
(aarch64_fnmadd<mode>4): Likewise.

From-SVN: r260292
gcc/ChangeLog
gcc/config/aarch64/aarch64.md