SelectionDAG: Prefer to combine multiplication with less uses for fma
authorJingyue Wu <jingyue@google.com>
Tue, 11 Aug 2015 19:21:46 +0000 (19:21 +0000)
committerJingyue Wu <jingyue@google.com>
Tue, 11 Aug 2015 19:21:46 +0000 (19:21 +0000)
commitd1ff8a7f6e7ff783a5096ef40f11397ebcf3a8f9
tree3651d272ff41c2b7434de245f6f0014599c32631
parentb9534620ad744c563fe584f5fd316c5d5c799c2c
SelectionDAG: Prefer to combine multiplication with less uses for fma

Summary:
For example:

  s6 = s0*s5;
  s2 = s6*s6 + s6;
  ...
  s4 = s6*s3;

We notice that it is possible for s2 is folded to fma (s0, s5, fmul (s6 s6)).
This only happens when Aggressive is true, otherwise hasOneUse() check
already prevents from folding the multiplication with more uses.

Test Plan: test/CodeGen/NVPTX/fma-assoc.ll

Patch by Xuetian Weng

Reviewers: hfinkel, apazos, jingyue, ohsallen, arsenm

Subscribers: arsenm, jholewinski, llvm-commits

Differential Revision: http://reviews.llvm.org/D11855

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244649 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/NVPTX/fma-assoc.ll