[InstCombine] fold fneg into constant operand of fmul/fdiv
authorSanjay Patel <spatel@rotateright.com>
Wed, 8 Aug 2018 14:29:08 +0000 (14:29 +0000)
committerSanjay Patel <spatel@rotateright.com>
Wed, 8 Aug 2018 14:29:08 +0000 (14:29 +0000)
commita194b2d2ffdd4c8400324fb5e105edd1f7a8d698
tree839ccff46529aeeda40bd2f2bdf0ddb1b7c8b69a
parent9f5b8f093eec7c71494d45cce89593adea37f5dd
[InstCombine] fold fneg into constant operand of fmul/fdiv

This accounts for the missing IR fold noted in D50195. We don't need any fast-math to enable the negation transform.
FP negation can always be folded into an fmul/fdiv constant to eliminate the fneg.

I've limited this to one-use to ensure that we are eliminating an instruction rather than replacing fneg by a
potentially expensive fdiv or fmul.

Differential Revision: https://reviews.llvm.org/D50417

llvm-svn: 339248
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/test/Transforms/InstCombine/fneg.ll
llvm/test/Transforms/InstCombine/fsub.ll