aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Constants.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2022-09-07 11:36:19 +0200
committerNikita Popov <npopov@redhat.com>2022-09-08 10:24:55 +0200
commit96cb7c22736bdd9e6b0194c933ae3b2986eae8e2 (patch)
tree1530fb3512d42055601431f3961996980f7330b3 /llvm/lib/IR/Constants.cpp
parent6247988e0751422fa10d70e64939c987dd3b81d9 (diff)
downloadllvm-96cb7c22736bdd9e6b0194c933ae3b2986eae8e2.zip
llvm-96cb7c22736bdd9e6b0194c933ae3b2986eae8e2.tar.gz
llvm-96cb7c22736bdd9e6b0194c933ae3b2986eae8e2.tar.bz2
[ConstantExpr] Remove fneg expression
As part of https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179, this removes the fneg constant expression (which is, incidentally, the only unary operator expression). Differential Revision: https://reviews.llvm.org/D133418
Diffstat (limited to 'llvm/lib/IR/Constants.cpp')
-rw-r--r--llvm/lib/IR/Constants.cpp46
1 files changed, 2 insertions, 44 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index b4a47db..6eecbb0 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -535,8 +535,8 @@ void llvm::deleteConstant(Constant *C) {
delete static_cast<PoisonValue *>(C);
break;
case Constant::ConstantExprVal:
- if (isa<UnaryConstantExpr>(C))
- delete static_cast<UnaryConstantExpr *>(C);
+ if (isa<CastConstantExpr>(C))
+ delete static_cast<CastConstantExpr *>(C);
else if (isa<BinaryConstantExpr>(C))
delete static_cast<BinaryConstantExpr *>(C);
else if (isa<SelectConstantExpr>(C))
@@ -1484,8 +1484,6 @@ Constant *ConstantExpr::getWithOperands(ArrayRef<Constant *> Ops, Type *Ty,
OnlyIfReducedTy);
case Instruction::ExtractElement:
return ConstantExpr::getExtractElement(Ops[0], Ops[1], OnlyIfReducedTy);
- case Instruction::FNeg:
- return ConstantExpr::getFNeg(Ops[0]);
case Instruction::ShuffleVector:
return ConstantExpr::getShuffleVector(Ops[0], Ops[1], getShuffleMask(),
OnlyIfReducedTy);
@@ -2230,37 +2228,6 @@ Constant *ConstantExpr::getAddrSpaceCast(Constant *C, Type *DstTy,
return getFoldedCast(Instruction::AddrSpaceCast, C, DstTy, OnlyIfReduced);
}
-Constant *ConstantExpr::get(unsigned Opcode, Constant *C, unsigned Flags,
- Type *OnlyIfReducedTy) {
- // Check the operands for consistency first.
- assert(Instruction::isUnaryOp(Opcode) &&
- "Invalid opcode in unary constant expression");
-
-#ifndef NDEBUG
- switch (Opcode) {
- case Instruction::FNeg:
- assert(C->getType()->isFPOrFPVectorTy() &&
- "Tried to create a floating-point operation on a "
- "non-floating-point type!");
- break;
- default:
- break;
- }
-#endif
-
- if (Constant *FC = ConstantFoldUnaryInstruction(Opcode, C))
- return FC;
-
- if (OnlyIfReducedTy == C->getType())
- return nullptr;
-
- Constant *ArgVec[] = { C };
- ConstantExprKeyType Key(Opcode, ArgVec, 0, Flags);
-
- LLVMContextImpl *pImpl = C->getContext().pImpl;
- return pImpl->ExprConstants.getOrCreate(C->getType(), Key);
-}
-
Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2,
unsigned Flags, Type *OnlyIfReducedTy) {
// Check the operands for consistency first.
@@ -2649,12 +2616,6 @@ Constant *ConstantExpr::getNeg(Constant *C, bool HasNUW, bool HasNSW) {
C, HasNUW, HasNSW);
}
-Constant *ConstantExpr::getFNeg(Constant *C) {
- assert(C->getType()->isFPOrFPVectorTy() &&
- "Cannot FNEG a non-floating-point value!");
- return get(Instruction::FNeg, C);
-}
-
Constant *ConstantExpr::getNot(Constant *C) {
assert(C->getType()->isIntOrIntVectorTy() &&
"Cannot NOT a nonintegral value!");
@@ -3470,9 +3431,6 @@ Instruction *ConstantExpr::getAsInstruction(Instruction *InsertBefore) const {
return CmpInst::Create((Instruction::OtherOps)getOpcode(),
(CmpInst::Predicate)getPredicate(), Ops[0], Ops[1],
"", InsertBefore);
- case Instruction::FNeg:
- return UnaryOperator::Create((Instruction::UnaryOps)getOpcode(), Ops[0], "",
- InsertBefore);
default:
assert(getNumOperands() == 2 && "Must be binary operator?");
BinaryOperator *BO = BinaryOperator::Create(