Fold single imm use of a FMA if it is a negation [PR95060]
authorJakub Jelinek <jakub@redhat.com>
Wed, 13 May 2020 09:21:02 +0000 (11:21 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 13 May 2020 09:21:02 +0000 (11:21 +0200)
commitc0c39a765b0714aed36fced6fbba452a6619acb0
tree117abca1f8030df99ba6d5b4e5d0ec7d1139edc8
parentf884bef21cccc05d748fd7869cd641cbb4f6b6bb
Fold single imm use of a FMA if it is a negation [PR95060]

match.pd already has simplifications for negation of a FMA (FMS, FNMA, FNMS)
call if it is single use, but when the widening_mul pass discovers FMAs,
nothing folds the statements anymore.

So, the following patch adjusts the widening_mul pass to handle that.

I had to adjust quite a lot of tests, because they have in them nested FMAs
(one FMA feeding another one) and the patch results in some (equivalent) changes
in the chosen instructions, previously the negation of one FMA's result
would result in the dependent FMA being adjusted for the negation, but now
instead the first FMA is adjusted.

2020-05-13  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/95060
* tree-ssa-math-opts.c (convert_mult_to_fma_1): Fold a NEGATE_EXPR
if it is the single use of the FMA internal builtin.

* gcc.target/i386/avx512f-pr95060.c: New test.
* gcc.target/i386/fma_double_1.c: Adjust expected insn counts.
* gcc.target/i386/fma_double_2.c: Likewise.
* gcc.target/i386/fma_double_3.c: Likewise.
* gcc.target/i386/fma_double_4.c: Likewise.
* gcc.target/i386/fma_double_5.c: Likewise.
* gcc.target/i386/fma_double_6.c: Likewise.
* gcc.target/i386/fma_float_1.c: Likewise.
* gcc.target/i386/fma_float_2.c: Likewise.
* gcc.target/i386/fma_float_3.c: Likewise.
* gcc.target/i386/fma_float_4.c: Likewise.
* gcc.target/i386/fma_float_5.c: Likewise.
* gcc.target/i386/fma_float_6.c: Likewise.
* gcc.target/i386/l_fma_double_1.c: Likewise.
* gcc.target/i386/l_fma_double_2.c: Likewise.
* gcc.target/i386/l_fma_double_3.c: Likewise.
* gcc.target/i386/l_fma_double_4.c: Likewise.
* gcc.target/i386/l_fma_double_5.c: Likewise.
* gcc.target/i386/l_fma_double_6.c: Likewise.
* gcc.target/i386/l_fma_float_1.c: Likewise.
* gcc.target/i386/l_fma_float_2.c: Likewise.
* gcc.target/i386/l_fma_float_3.c: Likewise.
* gcc.target/i386/l_fma_float_4.c: Likewise.
* gcc.target/i386/l_fma_float_5.c: Likewise.
* gcc.target/i386/l_fma_float_6.c: Likewise.
28 files changed:
gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/avx512f-pr95060.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/fma_double_1.c
gcc/testsuite/gcc.target/i386/fma_double_2.c
gcc/testsuite/gcc.target/i386/fma_double_3.c
gcc/testsuite/gcc.target/i386/fma_double_4.c
gcc/testsuite/gcc.target/i386/fma_double_5.c
gcc/testsuite/gcc.target/i386/fma_double_6.c
gcc/testsuite/gcc.target/i386/fma_float_1.c
gcc/testsuite/gcc.target/i386/fma_float_2.c
gcc/testsuite/gcc.target/i386/fma_float_3.c
gcc/testsuite/gcc.target/i386/fma_float_4.c
gcc/testsuite/gcc.target/i386/fma_float_5.c
gcc/testsuite/gcc.target/i386/fma_float_6.c
gcc/testsuite/gcc.target/i386/l_fma_double_1.c
gcc/testsuite/gcc.target/i386/l_fma_double_2.c
gcc/testsuite/gcc.target/i386/l_fma_double_3.c
gcc/testsuite/gcc.target/i386/l_fma_double_4.c
gcc/testsuite/gcc.target/i386/l_fma_double_5.c
gcc/testsuite/gcc.target/i386/l_fma_double_6.c
gcc/testsuite/gcc.target/i386/l_fma_float_1.c
gcc/testsuite/gcc.target/i386/l_fma_float_2.c
gcc/testsuite/gcc.target/i386/l_fma_float_3.c
gcc/testsuite/gcc.target/i386/l_fma_float_4.c
gcc/testsuite/gcc.target/i386/l_fma_float_5.c
gcc/testsuite/gcc.target/i386/l_fma_float_6.c
gcc/tree-ssa-math-opts.c