[InstCombine] fix/enhance fadd/fsub factorization
authorSanjay Patel <spatel@rotateright.com>
Sun, 12 Aug 2018 15:48:26 +0000 (15:48 +0000)
committerSanjay Patel <spatel@rotateright.com>
Sun, 12 Aug 2018 15:48:26 +0000 (15:48 +0000)
commitdc185ee27551c0ed5a66ca999bab6794c39b30f4
treeafee57201e33ebf319669c580162c45cda6deeb2
parentce104b6c1695d3c2110a13642a910218e19aabc0
[InstCombine] fix/enhance fadd/fsub factorization
  (X * Z) + (Y * Z) --> (X + Y) * Z
  (X * Z) - (Y * Z) --> (X - Y) * Z
  (X / Z) + (Y / Z) --> (X + Y) / Z
  (X / Z) - (Y / Z) --> (X - Y) / Z

The existing code that implemented these folds failed to
optimize vectors, and it transformed code with multiple
uses when it should not have.

llvm-svn: 339519
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/test/Transforms/InstCombine/fadd-fsub-factor.ll