diff options
author | Cameron McInally <cameron.mcinally@nyu.edu> | 2019-10-09 21:52:15 +0000 |
---|---|---|
committer | Cameron McInally <cameron.mcinally@nyu.edu> | 2019-10-09 21:52:15 +0000 |
commit | 47363a148f1d3003f0dd1cce234b60cdc8cc48bd (patch) | |
tree | 5342b6515520685da95e2b8a7ca4096b5a546ae7 /clang/lib/CodeGen/CGExprScalar.cpp | |
parent | 5da2bc22badde8748a71b1e8ad1ef0bd8e2ce386 (diff) | |
download | bcm5719-llvm-47363a148f1d3003f0dd1cce234b60cdc8cc48bd.tar.gz bcm5719-llvm-47363a148f1d3003f0dd1cce234b60cdc8cc48bd.zip |
[IRBuilder] Update IRBuilder::CreateFNeg(...) to return a UnaryOperator
Also update Clang to call Builder.CreateFNeg(...) for UnaryMinus.
Differential Revision: https://reviews.llvm.org/D61675
llvm-svn: 374240
Diffstat (limited to 'clang/lib/CodeGen/CGExprScalar.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index bff88b2feca..19b1cedf32e 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -2577,14 +2577,16 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV, Value *ScalarExprEmitter::VisitUnaryMinus(const UnaryOperator *E) { TestAndClearIgnoreResultAssign(); + Value *Op = Visit(E->getSubExpr()); + + // Generate a unary FNeg for FP ops. + if (Op->getType()->isFPOrFPVectorTy()) + return Builder.CreateFNeg(Op, "fneg"); + // Emit unary minus with EmitSub so we handle overflow cases etc. BinOpInfo BinOp; - BinOp.RHS = Visit(E->getSubExpr()); - - if (BinOp.RHS->getType()->isFPOrFPVectorTy()) - BinOp.LHS = llvm::ConstantFP::getZeroValueForNegation(BinOp.RHS->getType()); - else - BinOp.LHS = llvm::Constant::getNullValue(BinOp.RHS->getType()); + BinOp.RHS = Op; + BinOp.LHS = llvm::Constant::getNullValue(BinOp.RHS->getType()); BinOp.Ty = E->getType(); BinOp.Opcode = BO_Sub; // FIXME: once UnaryOperator carries FPFeatures, copy it here. |