Here's another subset of D61419. This patch contains the FNeg IR constant folding changes and some code in Analysis so that InstCombine can make use of it.
There are only two folds being performed right now:
fneg undef -> undef fneg C -> -C
New tests for those 2 folds have been added to the existing InstCombine fneg.ll tests (which are all fsub(-0.0, X) tests right now).
In addition to the new tests, there are quite a few existing tests in place that used to operate on fsub(-0.0, X), so coverage is pretty good. If you'd like to convince yourself of this, you can comment out the call to ConstantFoldUnaryInstruction(...) in lib/IR/Constants.cpp.
IIUC, this comment is wrong. If it fails, it returns a nullptr. No attempt is made to reduce a ConstExpr (ie, there is no SymbolicallyEvaluateUnOp()).
The existing comment below for binops looks misleading if I interpreted that correctly.