diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-07-03 17:12:59 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-07-03 17:12:59 +0000 |
commit | 8307bc407b55300393d402162bad90c487766f1f (patch) | |
tree | 9660e5ebc96f79f51a76a7428662b3ceb514ed01 /llvm/lib | |
parent | 2c38b7fd8b334995036ce3ec3e38c177e171affc (diff) | |
download | bcm5719-llvm-8307bc407b55300393d402162bad90c487766f1f.tar.gz bcm5719-llvm-8307bc407b55300393d402162bad90c487766f1f.zip |
[Constants] add identity constants for fadd/fmul
As the test diffs show, the current users of getBinOpIdentity()
are InstCombine and Reassociate. SLP vectorizer is a candidate
for using this functionality too (D28907).
The InstCombine shuffle improvements are part of the planned
enhancements noted in D48830.
InstCombine actually has several other uses of getBinOpIdentity()
via SimplifyUsingDistributiveLaws(), but we don't call that for
any FP ops. Fixing that might be another part of removing the
custom reassociation in InstCombine that is only done for fadd+fmul.
llvm-svn: 336215
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/IR/Constants.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 9b8670c7f3f..3ea7598c11e 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -2281,7 +2281,12 @@ Constant *ConstantExpr::getBinOpIdentity(unsigned Opcode, Type *Ty) { case Instruction::And: return Constant::getAllOnesValue(Ty); - // FIXME: FAdd / FMul? + // TODO: If the fadd has 'nsz', should we return +0.0? + case Instruction::FAdd: + return ConstantFP::getNegativeZero(Ty); + + case Instruction::FMul: + return ConstantFP::get(Ty, 1.0); } } |