middle-end: Fix FMA detection when inspecting gimple which have no LHS.
authorTamar Christina <tamar.christina@arm.com>
Thu, 18 Nov 2021 11:22:11 +0000 (11:22 +0000)
committerTamar Christina <tamar.christina@arm.com>
Thu, 18 Nov 2021 11:23:45 +0000 (11:23 +0000)
commit1a0bce98dcf84dd0a7b3ac67b51ac68758cc7ad0
tree7e5a8527c48a7d92533f5485b0b852bb35592e27
parentefb7c51024ccad9df293e6caf134d78b3d00cf89
middle-end: Fix FMA detection when inspecting gimple which have no LHS.

convert_mult_to_fma assumes that all gimple_assigns have a LHS set.  This
assumption is however not true when an IFN is kept around just for the
side-effects.  In those situations you have just the IFN and lhs will be null.

Since there's no LHS, there also can't be any ADD and such it can't be an FMA
so it's correct to just return early if no LHS.

gcc/ChangeLog:

PR tree-optimization/103253
* tree-ssa-math-opts.c (convert_mult_to_fma): Check for LHS.

gcc/testsuite/ChangeLog:

PR tree-optimization/103253
* gcc.dg/vect/pr103253.c: New test.
gcc/testsuite/gcc.dg/vect/pr103253.c [new file with mode: 0644]
gcc/tree-ssa-math-opts.c