[llvm] r345052 - [IR] remove fake binop queries for not/neg
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 23 10:06:03 PDT 2018
Author: spatel
Date: Tue Oct 23 10:06:03 2018
New Revision: 345052
URL: http://llvm.org/viewvc/llvm-project?rev=345052&view=rev
Log:
[IR] remove fake binop queries for not/neg
The initial motivation is that we want to remove the
fneg API because that would silently fail if we add
an actual fneg instruction to IR. The same would be
true for the integer ops, so we might as well get rid
of these too.
We have a newer 'match' API that makes checking for
these patterns simpler. It also works with vectors
that may include undef elements in constants.
If any out-of-tree users need updating, they can model
their code changes on these commits:
rL345050
rL345043
rL345042
rL345041
rL345036
rL345030
Modified:
llvm/trunk/include/llvm/IR/InstrTypes.h
llvm/trunk/lib/IR/Instructions.cpp
Modified: llvm/trunk/include/llvm/IR/InstrTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/InstrTypes.h?rev=345052&r1=345051&r2=345052&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/InstrTypes.h (original)
+++ llvm/trunk/include/llvm/IR/InstrTypes.h Tue Oct 23 10:06:03 2018
@@ -308,21 +308,12 @@ public:
static BinaryOperator *CreateNot(Value *Op, const Twine &Name,
BasicBlock *InsertAtEnd);
- /// Check if the given Value is a NEG, FNeg, or NOT instruction.
- ///
- static bool isNeg(const Value *V);
+ /// Check if the given Value is an FNeg instruction.
static bool isFNeg(const Value *V, bool IgnoreZeroSign=false);
- static bool isNot(const Value *V);
- /// Helper functions to extract the unary argument of a NEG, FNEG or NOT
- /// operation implemented via Sub, FSub, or Xor.
- ///
- static const Value *getNegArgument(const Value *BinOp);
- static Value *getNegArgument( Value *BinOp);
+ /// Helper functions to extract the unary argument of an FNeg.
static const Value *getFNegArgument(const Value *BinOp);
static Value *getFNegArgument( Value *BinOp);
- static const Value *getNotArgument(const Value *BinOp);
- static Value *getNotArgument( Value *BinOp);
BinaryOps getOpcode() const {
return static_cast<BinaryOps>(Instruction::getOpcode());
Modified: llvm/trunk/lib/IR/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instructions.cpp?rev=345052&r1=345051&r2=345052&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Instructions.cpp (original)
+++ llvm/trunk/lib/IR/Instructions.cpp Tue Oct 23 10:06:03 2018
@@ -2116,14 +2116,6 @@ static inline bool isConstantAllOnes(con
return false;
}
-bool BinaryOperator::isNeg(const Value *V) {
- if (const BinaryOperator *Bop = dyn_cast<BinaryOperator>(V))
- if (Bop->getOpcode() == Instruction::Sub)
- if (Constant *C = dyn_cast<Constant>(Bop->getOperand(0)))
- return C->isNegativeZeroValue();
- return false;
-}
-
bool BinaryOperator::isFNeg(const Value *V, bool IgnoreZeroSign) {
if (const BinaryOperator *Bop = dyn_cast<BinaryOperator>(V))
if (Bop->getOpcode() == Instruction::FSub)
@@ -2135,22 +2127,6 @@ bool BinaryOperator::isFNeg(const Value
return false;
}
-bool BinaryOperator::isNot(const Value *V) {
- if (const BinaryOperator *Bop = dyn_cast<BinaryOperator>(V))
- return (Bop->getOpcode() == Instruction::Xor &&
- (isConstantAllOnes(Bop->getOperand(1)) ||
- isConstantAllOnes(Bop->getOperand(0))));
- return false;
-}
-
-Value *BinaryOperator::getNegArgument(Value *BinOp) {
- return cast<BinaryOperator>(BinOp)->getOperand(1);
-}
-
-const Value *BinaryOperator::getNegArgument(const Value *BinOp) {
- return getNegArgument(const_cast<Value*>(BinOp));
-}
-
Value *BinaryOperator::getFNegArgument(Value *BinOp) {
return cast<BinaryOperator>(BinOp)->getOperand(1);
}
@@ -2159,21 +2135,6 @@ const Value *BinaryOperator::getFNegArgu
return getFNegArgument(const_cast<Value*>(BinOp));
}
-Value *BinaryOperator::getNotArgument(Value *BinOp) {
- assert(isNot(BinOp) && "getNotArgument on non-'not' instruction!");
- BinaryOperator *BO = cast<BinaryOperator>(BinOp);
- Value *Op0 = BO->getOperand(0);
- Value *Op1 = BO->getOperand(1);
- if (isConstantAllOnes(Op0)) return Op1;
-
- assert(isConstantAllOnes(Op1));
- return Op0;
-}
-
-const Value *BinaryOperator::getNotArgument(const Value *BinOp) {
- return getNotArgument(const_cast<Value*>(BinOp));
-}
-
// Exchange the two operands to this instruction. This instruction is safe to
// use on any binary instruction and does not modify the semantics of the
// instruction. If the instruction is order-dependent (SetLT f.e.), the opcode
More information about the llvm-commits
mailing list