Handle IFN_COND_MUL in tree-ssa-math-opts.c
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 30 Jul 2019 10:59:29 +0000 (10:59 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Tue, 30 Jul 2019 10:59:29 +0000 (10:59 +0000)
commitc1b3d827832f883e0634b18c88eb2bbde335aa42
tree74af98cf646a4ffe37dee618dc42f2a01020ce7b
parent8c955a4b9ca99dc1557dd4547068abf7a0838c8f
Handle IFN_COND_MUL in tree-ssa-math-opts.c

This patch extends the FMA handling in tree-ssa-math-opts.c so
that it can cope with conditional multiplications as well as
unconditional multiplications.  The addition or subtraction must then
have the same condition as the multiplication (at least for now).

E.g. we can currently fold:

  (IFN_COND_ADD cond (mul x y) z fallback)
    -> (IFN_COND_FMA cond x y z fallback)

This patch also allows:

  (IFN_COND_ADD cond (IFN_COND_MUL cond x y <whatever>) z fallback)
    -> (IFN_COND_FMA cond x y z fallback)

2019-07-30  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
* tree-ssa-math-opts.c (convert_mult_to_fma): Add a mul_cond
parameter.  When nonnull, make sure that the addition or subtraction
has the same condition.
(math_opts_dom_walker::after_dom_children): Try convert_mult_to_fma
for CFN_COND_MUL too.

gcc/testsuite/
* gcc.dg/vect/vect-cond-arith-7.c: New test.

From-SVN: r273905
gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/vect-cond-arith-7.c [new file with mode: 0644]
gcc/tree-ssa-math-opts.c