mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-30 04:35:00 +00:00
For PR970:
Clean up handling of isFloatingPoint() and dealing with PackedType. Patch by Gordon Henriksen! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33415 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
67f827ce5b
commit
24d6da5fed
@ -2867,7 +2867,7 @@ used to make a <i>no-op cast</i> because it always changes bits. Use
|
||||
|
||||
<!-- _______________________________________________________________________ -->
|
||||
<div class="doc_subsubsection">
|
||||
<a name="i_fp2uint">'<tt>fptoui .. to</tt>' Instruction</a>
|
||||
<a name="i_fptoui">'<tt>fptoui .. to</tt>' Instruction</a>
|
||||
</div>
|
||||
<div class="doc_text">
|
||||
|
||||
@ -3270,9 +3270,6 @@ yields a <a href="#t_primitive">i1</a> result, as follows:
|
||||
<li><tt>uno</tt>: yields <tt>true</tt> if either operand is a QNAN.</li>
|
||||
<li><tt>true</tt>: always yields <tt>true</tt>, regardless of operands.</li>
|
||||
</ol>
|
||||
<p>If the operands are <a href="#t_packed">packed</a> typed, the elements of
|
||||
the vector are compared in turn and the predicate must hold for all elements.
|
||||
</p>
|
||||
|
||||
<h5>Example:</h5>
|
||||
<pre> <result> = fcmp oeq float 4.0, 5.0 <i>; yields: result=false</i>
|
||||
|
@ -60,8 +60,7 @@ namespace llvm {
|
||||
/// loop (inserting one if there is none). A canonical induction variable
|
||||
/// starts at zero and steps by one on each iteration.
|
||||
Value *getOrInsertCanonicalInductionVariable(const Loop *L, const Type *Ty){
|
||||
assert((Ty->isInteger() || Ty->isFloatingPoint()) &&
|
||||
"Can only insert integer or floating point induction variables!");
|
||||
assert(Ty->isInteger() && "Can only insert integer induction variables!");
|
||||
SCEVHandle H = SCEVAddRecExpr::get(SCEVUnknown::getIntegerSCEV(0, Ty),
|
||||
SCEVUnknown::getIntegerSCEV(1, Ty), L);
|
||||
return expand(H);
|
||||
|
@ -36,7 +36,7 @@ template<class ConstantClass, class TypeClass>
|
||||
struct ConvertConstantType;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// This is the shared class of boolean and integrer constants. This class
|
||||
/// This is the shared class of boolean and integer constants. This class
|
||||
/// represents both boolean and integral constants.
|
||||
/// @brief Class for constant integers.
|
||||
class ConstantInt : public Constant {
|
||||
@ -585,6 +585,11 @@ public:
|
||||
static Constant *getInsertElement(Constant *Vec, Constant *Elt,Constant *Idx);
|
||||
static Constant *getShuffleVector(Constant *V1, Constant *V2, Constant *Mask);
|
||||
|
||||
/// Floating point negation must be implemented with f(x) = -0.0 - x. This
|
||||
/// method returns the negative zero constant for floating point or packed
|
||||
/// floating point types; for all other types, it returns the null value.
|
||||
static Constant *getZeroValueForNegationExpr(const Type *Ty);
|
||||
|
||||
/// isNullValue - Return true if this is the value that would be returned by
|
||||
/// getNullValue.
|
||||
virtual bool isNullValue() const { return false; }
|
||||
|
@ -305,37 +305,6 @@ m_FCmp(FCmpInst::Predicate &Pred, const LHS &L, const RHS &R) {
|
||||
// Matchers for unary operators
|
||||
//
|
||||
|
||||
template<typename LHS_t>
|
||||
struct neg_match {
|
||||
LHS_t L;
|
||||
|
||||
neg_match(const LHS_t &LHS) : L(LHS) {}
|
||||
|
||||
template<typename OpTy>
|
||||
bool match(OpTy *V) {
|
||||
if (Instruction *I = dyn_cast<Instruction>(V))
|
||||
if (I->getOpcode() == Instruction::Sub)
|
||||
return matchIfNeg(I->getOperand(0), I->getOperand(1));
|
||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
|
||||
if (CE->getOpcode() == Instruction::Sub)
|
||||
return matchIfNeg(CE->getOperand(0), CE->getOperand(1));
|
||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(V))
|
||||
return L.match(ConstantExpr::getNeg(CI));
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
bool matchIfNeg(Value *LHS, Value *RHS) {
|
||||
if (!LHS->getType()->isFloatingPoint())
|
||||
return LHS == Constant::getNullValue(LHS->getType()) && L.match(RHS);
|
||||
else
|
||||
return LHS == ConstantFP::get(LHS->getType(), -0.0) && L.match(RHS);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename LHS>
|
||||
inline neg_match<LHS> m_Neg(const LHS &L) { return L; }
|
||||
|
||||
|
||||
template<typename LHS_t>
|
||||
struct not_match {
|
||||
LHS_t L;
|
||||
|
@ -123,8 +123,7 @@ Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) {
|
||||
|
||||
// Insert a unit add instruction right before the terminator corresponding
|
||||
// to the back-edge.
|
||||
Constant *One = Ty->isFloatingPoint() ? (Constant*)ConstantFP::get(Ty, 1.0)
|
||||
: ConstantInt::get(Ty, 1);
|
||||
Constant *One = ConstantInt::get(Ty, 1);
|
||||
Instruction *Add = BinaryOperator::createAdd(PN, One, "indvar.next",
|
||||
(*HPI)->getTerminator());
|
||||
|
||||
|
@ -499,32 +499,37 @@ public:
|
||||
void visitInvoke(InvokeInst &I) { assert(0 && "TODO"); }
|
||||
void visitUnwind(UnwindInst &I) { assert(0 && "TODO"); }
|
||||
|
||||
void visitIntBinary(User &I, unsigned IntOp, unsigned VecOp);
|
||||
void visitFPBinary(User &I, unsigned FPOp, unsigned VecOp);
|
||||
void visitScalarBinary(User &I, unsigned OpCode);
|
||||
void visitVectorBinary(User &I, unsigned OpCode);
|
||||
void visitEitherBinary(User &I, unsigned ScalarOp, unsigned VectorOp);
|
||||
void visitShift(User &I, unsigned Opcode);
|
||||
void visitAdd(User &I) {
|
||||
if (I.getType()->isFloatingPoint())
|
||||
visitFPBinary(I, ISD::FADD, ISD::VADD);
|
||||
if (isa<PackedType>(I.getType()))
|
||||
visitVectorBinary(I, ISD::VADD);
|
||||
else if (I.getType()->isFloatingPoint())
|
||||
visitScalarBinary(I, ISD::FADD);
|
||||
else
|
||||
visitIntBinary(I, ISD::ADD, ISD::VADD);
|
||||
visitScalarBinary(I, ISD::ADD);
|
||||
}
|
||||
void visitSub(User &I);
|
||||
void visitMul(User &I) {
|
||||
if (I.getType()->isFloatingPoint())
|
||||
visitFPBinary(I, ISD::FMUL, ISD::VMUL);
|
||||
if (isa<PackedType>(I.getType()))
|
||||
visitVectorBinary(I, ISD::VMUL);
|
||||
else if (I.getType()->isFloatingPoint())
|
||||
visitScalarBinary(I, ISD::FMUL);
|
||||
else
|
||||
visitIntBinary(I, ISD::MUL, ISD::VMUL);
|
||||
visitScalarBinary(I, ISD::MUL);
|
||||
}
|
||||
void visitURem(User &I) { visitIntBinary(I, ISD::UREM, 0); }
|
||||
void visitSRem(User &I) { visitIntBinary(I, ISD::SREM, 0); }
|
||||
void visitFRem(User &I) { visitFPBinary (I, ISD::FREM, 0); }
|
||||
void visitUDiv(User &I) { visitIntBinary(I, ISD::UDIV, ISD::VUDIV); }
|
||||
void visitSDiv(User &I) { visitIntBinary(I, ISD::SDIV, ISD::VSDIV); }
|
||||
void visitFDiv(User &I) { visitFPBinary (I, ISD::FDIV, ISD::VSDIV); }
|
||||
void visitAnd(User &I) { visitIntBinary(I, ISD::AND, ISD::VAND); }
|
||||
void visitOr (User &I) { visitIntBinary(I, ISD::OR, ISD::VOR); }
|
||||
void visitXor(User &I) { visitIntBinary(I, ISD::XOR, ISD::VXOR); }
|
||||
void visitShl(User &I) { visitShift(I, ISD::SHL); }
|
||||
void visitURem(User &I) { visitScalarBinary(I, ISD::UREM); }
|
||||
void visitSRem(User &I) { visitScalarBinary(I, ISD::SREM); }
|
||||
void visitFRem(User &I) { visitScalarBinary(I, ISD::FREM); }
|
||||
void visitUDiv(User &I) { visitEitherBinary(I, ISD::UDIV, ISD::VUDIV); }
|
||||
void visitSDiv(User &I) { visitEitherBinary(I, ISD::SDIV, ISD::VSDIV); }
|
||||
void visitFDiv(User &I) { visitEitherBinary(I, ISD::FDIV, ISD::VSDIV); }
|
||||
void visitAnd (User &I) { visitEitherBinary(I, ISD::AND, ISD::VAND ); }
|
||||
void visitOr (User &I) { visitEitherBinary(I, ISD::OR, ISD::VOR ); }
|
||||
void visitXor (User &I) { visitEitherBinary(I, ISD::XOR, ISD::VXOR ); }
|
||||
void visitShl (User &I) { visitShift(I, ISD::SHL); }
|
||||
void visitLShr(User &I) { visitShift(I, ISD::SRL); }
|
||||
void visitAShr(User &I) { visitShift(I, ISD::SRA); }
|
||||
void visitICmp(User &I);
|
||||
@ -1369,46 +1374,47 @@ void SelectionDAGLowering::visitSwitch(SwitchInst &I) {
|
||||
|
||||
void SelectionDAGLowering::visitSub(User &I) {
|
||||
// -0.0 - X --> fneg
|
||||
if (I.getType()->isFloatingPoint()) {
|
||||
const Type *Ty = I.getType();
|
||||
if (isa<PackedType>(Ty)) {
|
||||
visitVectorBinary(I, ISD::VSUB);
|
||||
} else if (Ty->isFloatingPoint()) {
|
||||
if (ConstantFP *CFP = dyn_cast<ConstantFP>(I.getOperand(0)))
|
||||
if (CFP->isExactlyValue(-0.0)) {
|
||||
SDOperand Op2 = getValue(I.getOperand(1));
|
||||
setValue(&I, DAG.getNode(ISD::FNEG, Op2.getValueType(), Op2));
|
||||
return;
|
||||
}
|
||||
visitFPBinary(I, ISD::FSUB, ISD::VSUB);
|
||||
visitScalarBinary(I, ISD::FSUB);
|
||||
} else
|
||||
visitIntBinary(I, ISD::SUB, ISD::VSUB);
|
||||
visitScalarBinary(I, ISD::SUB);
|
||||
}
|
||||
|
||||
void
|
||||
SelectionDAGLowering::visitIntBinary(User &I, unsigned IntOp, unsigned VecOp) {
|
||||
const Type *Ty = I.getType();
|
||||
void SelectionDAGLowering::visitScalarBinary(User &I, unsigned OpCode) {
|
||||
SDOperand Op1 = getValue(I.getOperand(0));
|
||||
SDOperand Op2 = getValue(I.getOperand(1));
|
||||
|
||||
if (const PackedType *PTy = dyn_cast<PackedType>(Ty)) {
|
||||
SDOperand Num = DAG.getConstant(PTy->getNumElements(), MVT::i32);
|
||||
SDOperand Typ = DAG.getValueType(TLI.getValueType(PTy->getElementType()));
|
||||
setValue(&I, DAG.getNode(VecOp, MVT::Vector, Op1, Op2, Num, Typ));
|
||||
} else {
|
||||
setValue(&I, DAG.getNode(IntOp, Op1.getValueType(), Op1, Op2));
|
||||
}
|
||||
|
||||
setValue(&I, DAG.getNode(OpCode, Op1.getValueType(), Op1, Op2));
|
||||
}
|
||||
|
||||
void
|
||||
SelectionDAGLowering::visitFPBinary(User &I, unsigned FPOp, unsigned VecOp) {
|
||||
const Type *Ty = I.getType();
|
||||
SDOperand Op1 = getValue(I.getOperand(0));
|
||||
SDOperand Op2 = getValue(I.getOperand(1));
|
||||
void
|
||||
SelectionDAGLowering::visitVectorBinary(User &I, unsigned OpCode) {
|
||||
assert(isa<PackedType>(I.getType()));
|
||||
const PackedType *Ty = cast<PackedType>(I.getType());
|
||||
SDOperand Typ = DAG.getValueType(TLI.getValueType(Ty->getElementType()));
|
||||
|
||||
if (const PackedType *PTy = dyn_cast<PackedType>(Ty)) {
|
||||
SDOperand Num = DAG.getConstant(PTy->getNumElements(), MVT::i32);
|
||||
SDOperand Typ = DAG.getValueType(TLI.getValueType(PTy->getElementType()));
|
||||
setValue(&I, DAG.getNode(VecOp, MVT::Vector, Op1, Op2, Num, Typ));
|
||||
} else {
|
||||
setValue(&I, DAG.getNode(FPOp, Op1.getValueType(), Op1, Op2));
|
||||
}
|
||||
setValue(&I, DAG.getNode(OpCode, MVT::Vector,
|
||||
getValue(I.getOperand(0)),
|
||||
getValue(I.getOperand(1)),
|
||||
DAG.getConstant(Ty->getNumElements(), MVT::i32),
|
||||
Typ));
|
||||
}
|
||||
|
||||
void SelectionDAGLowering::visitEitherBinary(User &I, unsigned ScalarOp,
|
||||
unsigned VectorOp) {
|
||||
if (isa<PackedType>(I.getType()))
|
||||
visitVectorBinary(I, VectorOp);
|
||||
else
|
||||
visitScalarBinary(I, ScalarOp);
|
||||
}
|
||||
|
||||
void SelectionDAGLowering::visitShift(User &I, unsigned Opcode) {
|
||||
|
@ -1498,7 +1498,7 @@ GenericValue Interpreter::executeSIToFPInst(Value *SrcVal, const Type *DstTy,
|
||||
const IntegerType *SITy = cast<IntegerType>(SrcTy);
|
||||
unsigned SBitWidth = SITy->getBitWidth();
|
||||
assert(SBitWidth <= 64 && "Integer types > 64 bits not supported");
|
||||
assert(DstTy->isFloatingPoint() && "Invalid UIToFP instruction");
|
||||
assert(DstTy->isFloatingPoint() && "Invalid SIToFP instruction");
|
||||
int64_t Converted = 0;
|
||||
if (SBitWidth == 1)
|
||||
Converted = 0LL - Src.Int1Val;
|
||||
|
@ -576,8 +576,8 @@ static bool OperandConvertibleToType(User *U, Value *V, const Type *Ty,
|
||||
// Can convert store if the incoming value is convertible and if the
|
||||
// result will preserve semantics...
|
||||
const Type *Op0Ty = I->getOperand(0)->getType();
|
||||
if (!(Op0Ty->isInteger() ^ ElTy->isInteger()) &&
|
||||
!(Op0Ty->isFloatingPoint() ^ ElTy->isFloatingPoint()))
|
||||
if (Op0Ty->isInteger() == ElTy->isInteger() &&
|
||||
Op0Ty->isFloatingPoint() == ElTy->isFloatingPoint())
|
||||
return ExpressionConvertibleToType(I->getOperand(0), ElTy, CTMap, TD);
|
||||
}
|
||||
return false;
|
||||
|
@ -1343,6 +1343,7 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV,
|
||||
if (Constant *SOVConstant = dyn_cast<Constant>(GS.StoredOnceValue))
|
||||
if (GV->getType()->getElementType() != Type::Int1Ty &&
|
||||
!GV->getType()->getElementType()->isFloatingPoint() &&
|
||||
!isa<PackedType>(GV->getType()->getElementType()) &&
|
||||
!GS.HasPHIUser) {
|
||||
DOUT << " *** SHRINKING TO BOOL: " << *GV;
|
||||
ShrinkGlobalToBoolean(GV, SOVConstant);
|
||||
|
@ -186,11 +186,7 @@ static BinaryOperator *isReassociableOp(Value *V, unsigned Opcode) {
|
||||
/// LowerNegateToMultiply - Replace 0-X with X*-1.
|
||||
///
|
||||
static Instruction *LowerNegateToMultiply(Instruction *Neg) {
|
||||
Constant *Cst;
|
||||
if (Neg->getType()->isFloatingPoint())
|
||||
Cst = ConstantFP::get(Neg->getType(), -1);
|
||||
else
|
||||
Cst = ConstantInt::getAllOnesValue(Neg->getType());
|
||||
Constant *Cst = ConstantInt::getAllOnesValue(Neg->getType());
|
||||
|
||||
std::string NegName = Neg->getName(); Neg->setName("");
|
||||
Instruction *Res = BinaryOperator::createMul(Neg->getOperand(1), Cst, NegName,
|
||||
@ -661,32 +657,32 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I,
|
||||
std::map<Value*, unsigned> FactorOccurrences;
|
||||
unsigned MaxOcc = 0;
|
||||
Value *MaxOccVal = 0;
|
||||
if (!I->getType()->isFloatingPoint()) {
|
||||
for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
|
||||
if (BinaryOperator *BOp = dyn_cast<BinaryOperator>(Ops[i].Op))
|
||||
if (BOp->getOpcode() == Instruction::Mul && BOp->use_empty()) {
|
||||
// Compute all of the factors of this added value.
|
||||
std::vector<Value*> Factors;
|
||||
FindSingleUseMultiplyFactors(BOp, Factors);
|
||||
assert(Factors.size() > 1 && "Bad linearize!");
|
||||
|
||||
// Add one to FactorOccurrences for each unique factor in this op.
|
||||
if (Factors.size() == 2) {
|
||||
unsigned Occ = ++FactorOccurrences[Factors[0]];
|
||||
if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[0]; }
|
||||
if (Factors[0] != Factors[1]) { // Don't double count A*A.
|
||||
Occ = ++FactorOccurrences[Factors[1]];
|
||||
if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[1]; }
|
||||
for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
|
||||
if (BinaryOperator *BOp = dyn_cast<BinaryOperator>(Ops[i].Op)) {
|
||||
if (BOp->getOpcode() == Instruction::Mul && BOp->use_empty()) {
|
||||
// Compute all of the factors of this added value.
|
||||
std::vector<Value*> Factors;
|
||||
FindSingleUseMultiplyFactors(BOp, Factors);
|
||||
assert(Factors.size() > 1 && "Bad linearize!");
|
||||
|
||||
// Add one to FactorOccurrences for each unique factor in this op.
|
||||
if (Factors.size() == 2) {
|
||||
unsigned Occ = ++FactorOccurrences[Factors[0]];
|
||||
if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[0]; }
|
||||
if (Factors[0] != Factors[1]) { // Don't double count A*A.
|
||||
Occ = ++FactorOccurrences[Factors[1]];
|
||||
if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[1]; }
|
||||
}
|
||||
} else {
|
||||
std::set<Value*> Duplicates;
|
||||
for (unsigned i = 0, e = Factors.size(); i != e; ++i) {
|
||||
if (Duplicates.insert(Factors[i]).second) {
|
||||
unsigned Occ = ++FactorOccurrences[Factors[i]];
|
||||
if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[i]; }
|
||||
}
|
||||
} else {
|
||||
std::set<Value*> Duplicates;
|
||||
for (unsigned i = 0, e = Factors.size(); i != e; ++i)
|
||||
if (Duplicates.insert(Factors[i]).second) {
|
||||
unsigned Occ = ++FactorOccurrences[Factors[i]];
|
||||
if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[i]; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -519,7 +519,7 @@ const Type *SROA::CanConvertToScalar(Value *V, bool &IsNotTrivial) {
|
||||
return 0;
|
||||
|
||||
} else if (StoreInst *SI = dyn_cast<StoreInst>(User)) {
|
||||
// Storing the pointer, not the into the value?
|
||||
// Storing the pointer, not into the value?
|
||||
if (SI->getOperand(0) == V) return 0;
|
||||
|
||||
// NOTE: We could handle storing of FP imms into integers here!
|
||||
|
@ -378,10 +378,9 @@ bool ConstantExpr::isCompare() const {
|
||||
/// specify the full Instruction::OPCODE identifier.
|
||||
///
|
||||
Constant *ConstantExpr::getNeg(Constant *C) {
|
||||
if (!C->getType()->isFloatingPoint())
|
||||
return get(Instruction::Sub, getNullValue(C->getType()), C);
|
||||
else
|
||||
return get(Instruction::Sub, ConstantFP::get(C->getType(), -0.0), C);
|
||||
return get(Instruction::Sub,
|
||||
ConstantExpr::getZeroValueForNegationExpr(C->getType()),
|
||||
C);
|
||||
}
|
||||
Constant *ConstantExpr::getNot(Constant *C) {
|
||||
assert(isa<ConstantInt>(C) && "Cannot NOT a nonintegral type!");
|
||||
@ -1882,6 +1881,20 @@ Constant *ConstantExpr::getShuffleVector(Constant *V1, Constant *V2,
|
||||
return getShuffleVectorTy(V1->getType(), V1, V2, Mask);
|
||||
}
|
||||
|
||||
Constant *ConstantExpr::getZeroValueForNegationExpr(const Type *Ty) {
|
||||
if ((const PackedType *PTy = dyn_cast<PackedType>(Ty)) &&
|
||||
PTy->getElementType()->isFloatingPoint()) {
|
||||
std::vector<Constant*> zeros(PTy->getNumElements(),
|
||||
ConstantFP::get(PTy->getElementType(), -0.0));
|
||||
return ConstantPacked::get(PTy, zeros);
|
||||
}
|
||||
|
||||
if (Ty->isFloatingPoint())
|
||||
return ConstantFP::get(Ty, -0.0);
|
||||
|
||||
return Constant::getNullValue(Ty);
|
||||
}
|
||||
|
||||
// destroyConstant - Remove the constant from the constant table...
|
||||
//
|
||||
void ConstantExpr::destroyConstant() {
|
||||
|
@ -1092,26 +1092,18 @@ BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2,
|
||||
|
||||
BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name,
|
||||
Instruction *InsertBefore) {
|
||||
if (!Op->getType()->isFloatingPoint())
|
||||
return new BinaryOperator(Instruction::Sub,
|
||||
Constant::getNullValue(Op->getType()), Op,
|
||||
Op->getType(), Name, InsertBefore);
|
||||
else
|
||||
return new BinaryOperator(Instruction::Sub,
|
||||
ConstantFP::get(Op->getType(), -0.0), Op,
|
||||
Op->getType(), Name, InsertBefore);
|
||||
Value *zero = ConstantExpr::getZeroValueForNegationExpr(Op->getType());
|
||||
return new BinaryOperator(Instruction::Sub,
|
||||
zero, Op,
|
||||
Op->getType(), Name, InsertBefore);
|
||||
}
|
||||
|
||||
BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name,
|
||||
BasicBlock *InsertAtEnd) {
|
||||
if (!Op->getType()->isFloatingPoint())
|
||||
return new BinaryOperator(Instruction::Sub,
|
||||
Constant::getNullValue(Op->getType()), Op,
|
||||
Op->getType(), Name, InsertAtEnd);
|
||||
else
|
||||
return new BinaryOperator(Instruction::Sub,
|
||||
ConstantFP::get(Op->getType(), -0.0), Op,
|
||||
Op->getType(), Name, InsertAtEnd);
|
||||
Value *zero = ConstantExpr::getZeroValueForNegationExpr(Op->getType());
|
||||
return new BinaryOperator(Instruction::Sub,
|
||||
zero, Op,
|
||||
Op->getType(), Name, InsertAtEnd);
|
||||
}
|
||||
|
||||
BinaryOperator *BinaryOperator::createNot(Value *Op, const std::string &Name,
|
||||
@ -1153,10 +1145,8 @@ static inline bool isConstantAllOnes(const Value *V) {
|
||||
bool BinaryOperator::isNeg(const Value *V) {
|
||||
if (const BinaryOperator *Bop = dyn_cast<BinaryOperator>(V))
|
||||
if (Bop->getOpcode() == Instruction::Sub)
|
||||
if (!V->getType()->isFloatingPoint())
|
||||
return Bop->getOperand(0) == Constant::getNullValue(Bop->getType());
|
||||
else
|
||||
return Bop->getOperand(0) == ConstantFP::get(Bop->getType(), -0.0);
|
||||
return Bop->getOperand(0) ==
|
||||
ConstantExpr::getZeroValueForNegationExpr(Bop->getType());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1913,9 +1903,7 @@ CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS,
|
||||
assert(Op0Ty == Op1Ty &&
|
||||
"Both operands to ICmp instruction are not of the same type!");
|
||||
// Check that the operands are the right type
|
||||
assert(Op0Ty->isInteger() || isa<PointerType>(Op0Ty) ||
|
||||
(isa<PackedType>(Op0Ty) &&
|
||||
cast<PackedType>(Op0Ty)->getElementType()->isInteger()) &&
|
||||
assert((Op0Ty->isInteger() || isa<PointerType>(Op0Ty)) &&
|
||||
"Invalid operand types for ICmp instruction");
|
||||
return;
|
||||
}
|
||||
@ -1927,8 +1915,7 @@ CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS,
|
||||
assert(Op0Ty == Op1Ty &&
|
||||
"Both operands to FCmp instruction are not of the same type!");
|
||||
// Check that the operands are the right type
|
||||
assert(Op0Ty->isFloatingPoint() || (isa<PackedType>(Op0Ty) &&
|
||||
cast<PackedType>(Op0Ty)->getElementType()->isFloatingPoint()) &&
|
||||
assert(Op0Ty->isFloatingPoint() &&
|
||||
"Invalid operand types for FCmp instruction");
|
||||
}
|
||||
|
||||
@ -1948,9 +1935,7 @@ CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS,
|
||||
assert(Op0Ty == Op1Ty &&
|
||||
"Both operands to ICmp instruction are not of the same type!");
|
||||
// Check that the operands are the right type
|
||||
assert(Op0Ty->isInteger() || isa<PointerType>(Op0Ty) ||
|
||||
(isa<PackedType>(Op0Ty) &&
|
||||
cast<PackedType>(Op0Ty)->getElementType()->isInteger()) &&
|
||||
assert(Op0Ty->isInteger() || isa<PointerType>(Op0Ty) &&
|
||||
"Invalid operand types for ICmp instruction");
|
||||
return;
|
||||
}
|
||||
@ -1962,8 +1947,7 @@ CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS,
|
||||
assert(Op0Ty == Op1Ty &&
|
||||
"Both operands to FCmp instruction are not of the same type!");
|
||||
// Check that the operands are the right type
|
||||
assert(Op0Ty->isFloatingPoint() || (isa<PackedType>(Op0Ty) &&
|
||||
cast<PackedType>(Op0Ty)->getElementType()->isFloatingPoint()) &&
|
||||
assert(Op0Ty->isFloatingPoint() &&
|
||||
"Invalid operand types for FCmp instruction");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user