[IRBuilder] Move CreateNeg() to fold API
Remove the CreateNeg() method from IRBuilderFolder and base it on CreateSub(0, V) instead, which will call FoldNoWrapBinaryOp(). May not be NFC if InstSimplifyFolder is used.
This commit is contained in:
parent
5c8021777c
commit
21933b2f7f
|
@ -111,10 +111,6 @@ public:
|
||||||
// Unary Operators
|
// Unary Operators
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
|
||||||
Value *CreateNeg(Constant *C, bool HasNUW = false,
|
|
||||||
bool HasNSW = false) const override {
|
|
||||||
return ConstFolder.CreateNeg(C, HasNUW, HasNSW);
|
|
||||||
}
|
|
||||||
Value *CreateFNeg(Constant *C) const override {
|
Value *CreateFNeg(Constant *C) const override {
|
||||||
return ConstFolder.CreateFNeg(C);
|
return ConstFolder.CreateFNeg(C);
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,10 +168,6 @@ public:
|
||||||
// Unary Operators
|
// Unary Operators
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
|
||||||
Constant *CreateNeg(Constant *C,
|
|
||||||
bool HasNUW = false, bool HasNSW = false) const override {
|
|
||||||
return Fold(ConstantExpr::getNeg(C, HasNUW, HasNSW));
|
|
||||||
}
|
|
||||||
Constant *CreateFNeg(Constant *C) const override {
|
Constant *CreateFNeg(Constant *C) const override {
|
||||||
return Fold(ConstantExpr::getFNeg(C));
|
return Fold(ConstantExpr::getFNeg(C));
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,11 +158,6 @@ public:
|
||||||
// Unary Operators
|
// Unary Operators
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
|
||||||
Constant *CreateNeg(Constant *C,
|
|
||||||
bool HasNUW = false, bool HasNSW = false) const override {
|
|
||||||
return ConstantExpr::getNeg(C, HasNUW, HasNSW);
|
|
||||||
}
|
|
||||||
|
|
||||||
Constant *CreateFNeg(Constant *C) const override {
|
Constant *CreateFNeg(Constant *C) const override {
|
||||||
return ConstantExpr::getFNeg(C);
|
return ConstantExpr::getFNeg(C);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1572,14 +1572,10 @@ public:
|
||||||
Optional<RoundingMode> Rounding = None,
|
Optional<RoundingMode> Rounding = None,
|
||||||
Optional<fp::ExceptionBehavior> Except = None);
|
Optional<fp::ExceptionBehavior> Except = None);
|
||||||
|
|
||||||
Value *CreateNeg(Value *V, const Twine &Name = "",
|
Value *CreateNeg(Value *V, const Twine &Name = "", bool HasNUW = false,
|
||||||
bool HasNUW = false, bool HasNSW = false) {
|
bool HasNSW = false) {
|
||||||
if (auto *VC = dyn_cast<Constant>(V))
|
return CreateSub(Constant::getNullValue(V->getType()), V, Name, HasNUW,
|
||||||
return Insert(Folder.CreateNeg(VC, HasNUW, HasNSW), Name);
|
HasNSW);
|
||||||
BinaryOperator *BO = Insert(BinaryOperator::CreateNeg(V), Name);
|
|
||||||
if (HasNUW) BO->setHasNoUnsignedWrap();
|
|
||||||
if (HasNSW) BO->setHasNoSignedWrap();
|
|
||||||
return BO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value *CreateNSWNeg(Value *V, const Twine &Name = "") {
|
Value *CreateNSWNeg(Value *V, const Twine &Name = "") {
|
||||||
|
|
|
@ -71,8 +71,6 @@ public:
|
||||||
// Unary Operators
|
// Unary Operators
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
|
||||||
virtual Value *CreateNeg(Constant *C,
|
|
||||||
bool HasNUW = false, bool HasNSW = false) const = 0;
|
|
||||||
virtual Value *CreateFNeg(Constant *C) const = 0;
|
virtual Value *CreateFNeg(Constant *C) const = 0;
|
||||||
virtual Value *CreateUnOp(Instruction::UnaryOps Opc, Constant *C) const = 0;
|
virtual Value *CreateUnOp(Instruction::UnaryOps Opc, Constant *C) const = 0;
|
||||||
|
|
||||||
|
|
|
@ -106,15 +106,6 @@ public:
|
||||||
// Unary Operators
|
// Unary Operators
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
|
||||||
Instruction *CreateNeg(Constant *C,
|
|
||||||
bool HasNUW = false,
|
|
||||||
bool HasNSW = false) const override {
|
|
||||||
BinaryOperator *BO = BinaryOperator::CreateNeg(C);
|
|
||||||
if (HasNUW) BO->setHasNoUnsignedWrap();
|
|
||||||
if (HasNSW) BO->setHasNoSignedWrap();
|
|
||||||
return BO;
|
|
||||||
}
|
|
||||||
|
|
||||||
Instruction *CreateFNeg(Constant *C) const override {
|
Instruction *CreateFNeg(Constant *C) const override {
|
||||||
return UnaryOperator::CreateFNeg(C);
|
return UnaryOperator::CreateFNeg(C);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue