]> git.ipfire.org Git - thirdparty/gcc.git/commit
match.pd: Improve fneg/fadd optimization [PR109240]
authorJakub Jelinek <jakub@redhat.com>
Tue, 18 Apr 2023 09:01:47 +0000 (11:01 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 18 Apr 2023 09:01:47 +0000 (11:01 +0200)
commit2349e69125335d4c8c5e43cf3643844519d154c3
treebff999304803056bbc2d8174fa1a95715438ec3e
parent6e552ec218a04dac046066e2608202ba90d66f11
match.pd: Improve fneg/fadd optimization [PR109240]

match.pd has mostly for AArch64 an optimization in which it optimizes
certain forms of __builtin_shuffle of x + y and x - y vectors into
fneg using twice as wide element type so that every other sign is changed,
followed by fadd.

The following patch extends that optimization, so that it can handle
other forms as well, using the same fneg but fsub instead of fadd.

As the plus is commutative and minus is not and I want to handle
vec_perm with plus minus and minus plus order preferrably in one
pattern, I had to do the matching operand checks by hand.

2023-04-18  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/109240
* match.pd (fneg/fadd): Rewrite such that it handles both plus as
first vec_perm operand and minus as second using fneg/fadd and
minus as first vec_perm operand and plus as second using fneg/fsub.

* gcc.target/aarch64/simd/addsub_2.c: New test.
* gcc.target/aarch64/sve/addsub_2.c: New test.
gcc/match.pd
gcc/testsuite/gcc.target/aarch64/simd/addsub_2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/addsub_2.c [new file with mode: 0644]