forked from OSchip/llvm-project
[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 llvm-svn: 345052
This commit is contained in:
parent
70b6bbe2bb
commit
07076cfdf6
|
@ -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());
|
||||
|
|
|
@ -2116,14 +2116,6 @@ static inline bool isConstantAllOnes(const Value *V) {
|
|||
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 *V, bool IgnoreZeroSign) {
|
|||
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::getFNegArgument(const Value *BinOp) {
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue