match.pd: Fix up fneg/fadd simplification [PR109230]
authorJakub Jelinek <jakub@redhat.com>
Sun, 26 Mar 2023 18:17:00 +0000 (20:17 +0200)
committerJakub Jelinek <jakub@redhat.com>
Sun, 26 Mar 2023 18:17:00 +0000 (20:17 +0200)
commit07fc3491260e6b5d261433c977a4e069f5ab40c1
tree2a9e40da01bf6082120cbae573aaf1b35bc023c3
parent7eca91d4781bb3df941f25c30b971dac66ba1b3d
match.pd: Fix up fneg/fadd simplification [PR109230]

The following testcase is miscompiled on aarch64-linux.  match.pd
has a simplification for addsub, where it negates one of the vectors
in twice as large floating point element vector (effectively negating every
other element) and then doing addition.
But a requirement for that is that the permutation picks the right elements,
in particular 0, nelts+1, 2, nelts+3, 4, nelts+5, ...
The pattern tests this with sel.series_p (0, 2, 0, 2) check, which as
documented verifies that the even elements of the permutation mask are
identity, but doesn't say anything about the others.
The following patch fixes it by also checking that the odd elements
start at nelts + 1 with the same step of 2.

2023-03-26  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/109230
* match.pd (fneg/fadd simplify): Verify also odd permutation indexes.

* gcc.dg/pr109230.c: New test.
gcc/match.pd
gcc/testsuite/gcc.dg/pr109230.c [new file with mode: 0644]