mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 05:29:24 +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">
|
<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>
|
||||||
<div class="doc_text">
|
<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>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>
|
<li><tt>true</tt>: always yields <tt>true</tt>, regardless of operands.</li>
|
||||||
</ol>
|
</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>
|
<h5>Example:</h5>
|
||||||
<pre> <result> = fcmp oeq float 4.0, 5.0 <i>; yields: result=false</i>
|
<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
|
/// loop (inserting one if there is none). A canonical induction variable
|
||||||
/// starts at zero and steps by one on each iteration.
|
/// starts at zero and steps by one on each iteration.
|
||||||
Value *getOrInsertCanonicalInductionVariable(const Loop *L, const Type *Ty){
|
Value *getOrInsertCanonicalInductionVariable(const Loop *L, const Type *Ty){
|
||||||
assert((Ty->isInteger() || Ty->isFloatingPoint()) &&
|
assert(Ty->isInteger() && "Can only insert integer induction variables!");
|
||||||
"Can only insert integer or floating point induction variables!");
|
|
||||||
SCEVHandle H = SCEVAddRecExpr::get(SCEVUnknown::getIntegerSCEV(0, Ty),
|
SCEVHandle H = SCEVAddRecExpr::get(SCEVUnknown::getIntegerSCEV(0, Ty),
|
||||||
SCEVUnknown::getIntegerSCEV(1, Ty), L);
|
SCEVUnknown::getIntegerSCEV(1, Ty), L);
|
||||||
return expand(H);
|
return expand(H);
|
||||||
|
@ -36,7 +36,7 @@ template<class ConstantClass, class TypeClass>
|
|||||||
struct ConvertConstantType;
|
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.
|
/// represents both boolean and integral constants.
|
||||||
/// @brief Class for constant integers.
|
/// @brief Class for constant integers.
|
||||||
class ConstantInt : public Constant {
|
class ConstantInt : public Constant {
|
||||||
@ -585,6 +585,11 @@ public:
|
|||||||
static Constant *getInsertElement(Constant *Vec, Constant *Elt,Constant *Idx);
|
static Constant *getInsertElement(Constant *Vec, Constant *Elt,Constant *Idx);
|
||||||
static Constant *getShuffleVector(Constant *V1, Constant *V2, Constant *Mask);
|
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
|
/// isNullValue - Return true if this is the value that would be returned by
|
||||||
/// getNullValue.
|
/// getNullValue.
|
||||||
virtual bool isNullValue() const { return false; }
|
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
|
// 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>
|
template<typename LHS_t>
|
||||||
struct not_match {
|
struct not_match {
|
||||||
LHS_t L;
|
LHS_t L;
|
||||||
|
@ -123,8 +123,7 @@ Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) {
|
|||||||
|
|
||||||
// Insert a unit add instruction right before the terminator corresponding
|
// Insert a unit add instruction right before the terminator corresponding
|
||||||
// to the back-edge.
|
// to the back-edge.
|
||||||
Constant *One = Ty->isFloatingPoint() ? (Constant*)ConstantFP::get(Ty, 1.0)
|
Constant *One = ConstantInt::get(Ty, 1);
|
||||||
: ConstantInt::get(Ty, 1);
|
|
||||||
Instruction *Add = BinaryOperator::createAdd(PN, One, "indvar.next",
|
Instruction *Add = BinaryOperator::createAdd(PN, One, "indvar.next",
|
||||||
(*HPI)->getTerminator());
|
(*HPI)->getTerminator());
|
||||||
|
|
||||||
|
@ -499,31 +499,36 @@ public:
|
|||||||
void visitInvoke(InvokeInst &I) { assert(0 && "TODO"); }
|
void visitInvoke(InvokeInst &I) { assert(0 && "TODO"); }
|
||||||
void visitUnwind(UnwindInst &I) { assert(0 && "TODO"); }
|
void visitUnwind(UnwindInst &I) { assert(0 && "TODO"); }
|
||||||
|
|
||||||
void visitIntBinary(User &I, unsigned IntOp, unsigned VecOp);
|
void visitScalarBinary(User &I, unsigned OpCode);
|
||||||
void visitFPBinary(User &I, unsigned FPOp, unsigned VecOp);
|
void visitVectorBinary(User &I, unsigned OpCode);
|
||||||
|
void visitEitherBinary(User &I, unsigned ScalarOp, unsigned VectorOp);
|
||||||
void visitShift(User &I, unsigned Opcode);
|
void visitShift(User &I, unsigned Opcode);
|
||||||
void visitAdd(User &I) {
|
void visitAdd(User &I) {
|
||||||
if (I.getType()->isFloatingPoint())
|
if (isa<PackedType>(I.getType()))
|
||||||
visitFPBinary(I, ISD::FADD, ISD::VADD);
|
visitVectorBinary(I, ISD::VADD);
|
||||||
|
else if (I.getType()->isFloatingPoint())
|
||||||
|
visitScalarBinary(I, ISD::FADD);
|
||||||
else
|
else
|
||||||
visitIntBinary(I, ISD::ADD, ISD::VADD);
|
visitScalarBinary(I, ISD::ADD);
|
||||||
}
|
}
|
||||||
void visitSub(User &I);
|
void visitSub(User &I);
|
||||||
void visitMul(User &I) {
|
void visitMul(User &I) {
|
||||||
if (I.getType()->isFloatingPoint())
|
if (isa<PackedType>(I.getType()))
|
||||||
visitFPBinary(I, ISD::FMUL, ISD::VMUL);
|
visitVectorBinary(I, ISD::VMUL);
|
||||||
|
else if (I.getType()->isFloatingPoint())
|
||||||
|
visitScalarBinary(I, ISD::FMUL);
|
||||||
else
|
else
|
||||||
visitIntBinary(I, ISD::MUL, ISD::VMUL);
|
visitScalarBinary(I, ISD::MUL);
|
||||||
}
|
}
|
||||||
void visitURem(User &I) { visitIntBinary(I, ISD::UREM, 0); }
|
void visitURem(User &I) { visitScalarBinary(I, ISD::UREM); }
|
||||||
void visitSRem(User &I) { visitIntBinary(I, ISD::SREM, 0); }
|
void visitSRem(User &I) { visitScalarBinary(I, ISD::SREM); }
|
||||||
void visitFRem(User &I) { visitFPBinary (I, ISD::FREM, 0); }
|
void visitFRem(User &I) { visitScalarBinary(I, ISD::FREM); }
|
||||||
void visitUDiv(User &I) { visitIntBinary(I, ISD::UDIV, ISD::VUDIV); }
|
void visitUDiv(User &I) { visitEitherBinary(I, ISD::UDIV, ISD::VUDIV); }
|
||||||
void visitSDiv(User &I) { visitIntBinary(I, ISD::SDIV, ISD::VSDIV); }
|
void visitSDiv(User &I) { visitEitherBinary(I, ISD::SDIV, ISD::VSDIV); }
|
||||||
void visitFDiv(User &I) { visitFPBinary (I, ISD::FDIV, ISD::VSDIV); }
|
void visitFDiv(User &I) { visitEitherBinary(I, ISD::FDIV, ISD::VSDIV); }
|
||||||
void visitAnd(User &I) { visitIntBinary(I, ISD::AND, ISD::VAND); }
|
void visitAnd (User &I) { visitEitherBinary(I, ISD::AND, ISD::VAND ); }
|
||||||
void visitOr (User &I) { visitIntBinary(I, ISD::OR, ISD::VOR); }
|
void visitOr (User &I) { visitEitherBinary(I, ISD::OR, ISD::VOR ); }
|
||||||
void visitXor(User &I) { visitIntBinary(I, ISD::XOR, ISD::VXOR); }
|
void visitXor (User &I) { visitEitherBinary(I, ISD::XOR, ISD::VXOR ); }
|
||||||
void visitShl (User &I) { visitShift(I, ISD::SHL); }
|
void visitShl (User &I) { visitShift(I, ISD::SHL); }
|
||||||
void visitLShr(User &I) { visitShift(I, ISD::SRL); }
|
void visitLShr(User &I) { visitShift(I, ISD::SRL); }
|
||||||
void visitAShr(User &I) { visitShift(I, ISD::SRA); }
|
void visitAShr(User &I) { visitShift(I, ISD::SRA); }
|
||||||
@ -1369,46 +1374,47 @@ void SelectionDAGLowering::visitSwitch(SwitchInst &I) {
|
|||||||
|
|
||||||
void SelectionDAGLowering::visitSub(User &I) {
|
void SelectionDAGLowering::visitSub(User &I) {
|
||||||
// -0.0 - X --> fneg
|
// -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 (ConstantFP *CFP = dyn_cast<ConstantFP>(I.getOperand(0)))
|
||||||
if (CFP->isExactlyValue(-0.0)) {
|
if (CFP->isExactlyValue(-0.0)) {
|
||||||
SDOperand Op2 = getValue(I.getOperand(1));
|
SDOperand Op2 = getValue(I.getOperand(1));
|
||||||
setValue(&I, DAG.getNode(ISD::FNEG, Op2.getValueType(), Op2));
|
setValue(&I, DAG.getNode(ISD::FNEG, Op2.getValueType(), Op2));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
visitFPBinary(I, ISD::FSUB, ISD::VSUB);
|
visitScalarBinary(I, ISD::FSUB);
|
||||||
} else
|
} else
|
||||||
visitIntBinary(I, ISD::SUB, ISD::VSUB);
|
visitScalarBinary(I, ISD::SUB);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SelectionDAGLowering::visitScalarBinary(User &I, unsigned OpCode) {
|
||||||
SelectionDAGLowering::visitIntBinary(User &I, unsigned IntOp, unsigned VecOp) {
|
|
||||||
const Type *Ty = I.getType();
|
|
||||||
SDOperand Op1 = getValue(I.getOperand(0));
|
SDOperand Op1 = getValue(I.getOperand(0));
|
||||||
SDOperand Op2 = getValue(I.getOperand(1));
|
SDOperand Op2 = getValue(I.getOperand(1));
|
||||||
|
|
||||||
if (const PackedType *PTy = dyn_cast<PackedType>(Ty)) {
|
setValue(&I, DAG.getNode(OpCode, Op1.getValueType(), Op1, Op2));
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SelectionDAGLowering::visitFPBinary(User &I, unsigned FPOp, unsigned VecOp) {
|
SelectionDAGLowering::visitVectorBinary(User &I, unsigned OpCode) {
|
||||||
const Type *Ty = I.getType();
|
assert(isa<PackedType>(I.getType()));
|
||||||
SDOperand Op1 = getValue(I.getOperand(0));
|
const PackedType *Ty = cast<PackedType>(I.getType());
|
||||||
SDOperand Op2 = getValue(I.getOperand(1));
|
SDOperand Typ = DAG.getValueType(TLI.getValueType(Ty->getElementType()));
|
||||||
|
|
||||||
if (const PackedType *PTy = dyn_cast<PackedType>(Ty)) {
|
setValue(&I, DAG.getNode(OpCode, MVT::Vector,
|
||||||
SDOperand Num = DAG.getConstant(PTy->getNumElements(), MVT::i32);
|
getValue(I.getOperand(0)),
|
||||||
SDOperand Typ = DAG.getValueType(TLI.getValueType(PTy->getElementType()));
|
getValue(I.getOperand(1)),
|
||||||
setValue(&I, DAG.getNode(VecOp, MVT::Vector, Op1, Op2, Num, Typ));
|
DAG.getConstant(Ty->getNumElements(), MVT::i32),
|
||||||
} else {
|
Typ));
|
||||||
setValue(&I, DAG.getNode(FPOp, Op1.getValueType(), Op1, Op2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
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);
|
const IntegerType *SITy = cast<IntegerType>(SrcTy);
|
||||||
unsigned SBitWidth = SITy->getBitWidth();
|
unsigned SBitWidth = SITy->getBitWidth();
|
||||||
assert(SBitWidth <= 64 && "Integer types > 64 bits not supported");
|
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;
|
int64_t Converted = 0;
|
||||||
if (SBitWidth == 1)
|
if (SBitWidth == 1)
|
||||||
Converted = 0LL - Src.Int1Val;
|
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
|
// Can convert store if the incoming value is convertible and if the
|
||||||
// result will preserve semantics...
|
// result will preserve semantics...
|
||||||
const Type *Op0Ty = I->getOperand(0)->getType();
|
const Type *Op0Ty = I->getOperand(0)->getType();
|
||||||
if (!(Op0Ty->isInteger() ^ ElTy->isInteger()) &&
|
if (Op0Ty->isInteger() == ElTy->isInteger() &&
|
||||||
!(Op0Ty->isFloatingPoint() ^ ElTy->isFloatingPoint()))
|
Op0Ty->isFloatingPoint() == ElTy->isFloatingPoint())
|
||||||
return ExpressionConvertibleToType(I->getOperand(0), ElTy, CTMap, TD);
|
return ExpressionConvertibleToType(I->getOperand(0), ElTy, CTMap, TD);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1343,6 +1343,7 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV,
|
|||||||
if (Constant *SOVConstant = dyn_cast<Constant>(GS.StoredOnceValue))
|
if (Constant *SOVConstant = dyn_cast<Constant>(GS.StoredOnceValue))
|
||||||
if (GV->getType()->getElementType() != Type::Int1Ty &&
|
if (GV->getType()->getElementType() != Type::Int1Ty &&
|
||||||
!GV->getType()->getElementType()->isFloatingPoint() &&
|
!GV->getType()->getElementType()->isFloatingPoint() &&
|
||||||
|
!isa<PackedType>(GV->getType()->getElementType()) &&
|
||||||
!GS.HasPHIUser) {
|
!GS.HasPHIUser) {
|
||||||
DOUT << " *** SHRINKING TO BOOL: " << *GV;
|
DOUT << " *** SHRINKING TO BOOL: " << *GV;
|
||||||
ShrinkGlobalToBoolean(GV, SOVConstant);
|
ShrinkGlobalToBoolean(GV, SOVConstant);
|
||||||
|
@ -186,11 +186,7 @@ static BinaryOperator *isReassociableOp(Value *V, unsigned Opcode) {
|
|||||||
/// LowerNegateToMultiply - Replace 0-X with X*-1.
|
/// LowerNegateToMultiply - Replace 0-X with X*-1.
|
||||||
///
|
///
|
||||||
static Instruction *LowerNegateToMultiply(Instruction *Neg) {
|
static Instruction *LowerNegateToMultiply(Instruction *Neg) {
|
||||||
Constant *Cst;
|
Constant *Cst = ConstantInt::getAllOnesValue(Neg->getType());
|
||||||
if (Neg->getType()->isFloatingPoint())
|
|
||||||
Cst = ConstantFP::get(Neg->getType(), -1);
|
|
||||||
else
|
|
||||||
Cst = ConstantInt::getAllOnesValue(Neg->getType());
|
|
||||||
|
|
||||||
std::string NegName = Neg->getName(); Neg->setName("");
|
std::string NegName = Neg->getName(); Neg->setName("");
|
||||||
Instruction *Res = BinaryOperator::createMul(Neg->getOperand(1), Cst, NegName,
|
Instruction *Res = BinaryOperator::createMul(Neg->getOperand(1), Cst, NegName,
|
||||||
@ -661,9 +657,8 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I,
|
|||||||
std::map<Value*, unsigned> FactorOccurrences;
|
std::map<Value*, unsigned> FactorOccurrences;
|
||||||
unsigned MaxOcc = 0;
|
unsigned MaxOcc = 0;
|
||||||
Value *MaxOccVal = 0;
|
Value *MaxOccVal = 0;
|
||||||
if (!I->getType()->isFloatingPoint()) {
|
|
||||||
for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
|
||||||
if (BinaryOperator *BOp = dyn_cast<BinaryOperator>(Ops[i].Op))
|
if (BinaryOperator *BOp = dyn_cast<BinaryOperator>(Ops[i].Op)) {
|
||||||
if (BOp->getOpcode() == Instruction::Mul && BOp->use_empty()) {
|
if (BOp->getOpcode() == Instruction::Mul && BOp->use_empty()) {
|
||||||
// Compute all of the factors of this added value.
|
// Compute all of the factors of this added value.
|
||||||
std::vector<Value*> Factors;
|
std::vector<Value*> Factors;
|
||||||
@ -680,7 +675,7 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::set<Value*> Duplicates;
|
std::set<Value*> Duplicates;
|
||||||
for (unsigned i = 0, e = Factors.size(); i != e; ++i)
|
for (unsigned i = 0, e = Factors.size(); i != e; ++i) {
|
||||||
if (Duplicates.insert(Factors[i]).second) {
|
if (Duplicates.insert(Factors[i]).second) {
|
||||||
unsigned Occ = ++FactorOccurrences[Factors[i]];
|
unsigned Occ = ++FactorOccurrences[Factors[i]];
|
||||||
if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[i]; }
|
if (Occ > MaxOcc) { MaxOcc = Occ; MaxOccVal = Factors[i]; }
|
||||||
@ -689,6 +684,7 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If any factor occurred more than one time, we can pull it out.
|
// If any factor occurred more than one time, we can pull it out.
|
||||||
if (MaxOcc > 1) {
|
if (MaxOcc > 1) {
|
||||||
|
@ -519,7 +519,7 @@ const Type *SROA::CanConvertToScalar(Value *V, bool &IsNotTrivial) {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
} else if (StoreInst *SI = dyn_cast<StoreInst>(User)) {
|
} 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;
|
if (SI->getOperand(0) == V) return 0;
|
||||||
|
|
||||||
// NOTE: We could handle storing of FP imms into integers here!
|
// 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.
|
/// specify the full Instruction::OPCODE identifier.
|
||||||
///
|
///
|
||||||
Constant *ConstantExpr::getNeg(Constant *C) {
|
Constant *ConstantExpr::getNeg(Constant *C) {
|
||||||
if (!C->getType()->isFloatingPoint())
|
return get(Instruction::Sub,
|
||||||
return get(Instruction::Sub, getNullValue(C->getType()), C);
|
ConstantExpr::getZeroValueForNegationExpr(C->getType()),
|
||||||
else
|
C);
|
||||||
return get(Instruction::Sub, ConstantFP::get(C->getType(), -0.0), C);
|
|
||||||
}
|
}
|
||||||
Constant *ConstantExpr::getNot(Constant *C) {
|
Constant *ConstantExpr::getNot(Constant *C) {
|
||||||
assert(isa<ConstantInt>(C) && "Cannot NOT a nonintegral type!");
|
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);
|
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...
|
// destroyConstant - Remove the constant from the constant table...
|
||||||
//
|
//
|
||||||
void ConstantExpr::destroyConstant() {
|
void ConstantExpr::destroyConstant() {
|
||||||
|
@ -1092,25 +1092,17 @@ BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2,
|
|||||||
|
|
||||||
BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name,
|
BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name,
|
||||||
Instruction *InsertBefore) {
|
Instruction *InsertBefore) {
|
||||||
if (!Op->getType()->isFloatingPoint())
|
Value *zero = ConstantExpr::getZeroValueForNegationExpr(Op->getType());
|
||||||
return new BinaryOperator(Instruction::Sub,
|
return new BinaryOperator(Instruction::Sub,
|
||||||
Constant::getNullValue(Op->getType()), Op,
|
zero, Op,
|
||||||
Op->getType(), Name, InsertBefore);
|
|
||||||
else
|
|
||||||
return new BinaryOperator(Instruction::Sub,
|
|
||||||
ConstantFP::get(Op->getType(), -0.0), Op,
|
|
||||||
Op->getType(), Name, InsertBefore);
|
Op->getType(), Name, InsertBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name,
|
BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name,
|
||||||
BasicBlock *InsertAtEnd) {
|
BasicBlock *InsertAtEnd) {
|
||||||
if (!Op->getType()->isFloatingPoint())
|
Value *zero = ConstantExpr::getZeroValueForNegationExpr(Op->getType());
|
||||||
return new BinaryOperator(Instruction::Sub,
|
return new BinaryOperator(Instruction::Sub,
|
||||||
Constant::getNullValue(Op->getType()), Op,
|
zero, Op,
|
||||||
Op->getType(), Name, InsertAtEnd);
|
|
||||||
else
|
|
||||||
return new BinaryOperator(Instruction::Sub,
|
|
||||||
ConstantFP::get(Op->getType(), -0.0), Op,
|
|
||||||
Op->getType(), Name, InsertAtEnd);
|
Op->getType(), Name, InsertAtEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1153,10 +1145,8 @@ static inline bool isConstantAllOnes(const Value *V) {
|
|||||||
bool BinaryOperator::isNeg(const Value *V) {
|
bool BinaryOperator::isNeg(const Value *V) {
|
||||||
if (const BinaryOperator *Bop = dyn_cast<BinaryOperator>(V))
|
if (const BinaryOperator *Bop = dyn_cast<BinaryOperator>(V))
|
||||||
if (Bop->getOpcode() == Instruction::Sub)
|
if (Bop->getOpcode() == Instruction::Sub)
|
||||||
if (!V->getType()->isFloatingPoint())
|
return Bop->getOperand(0) ==
|
||||||
return Bop->getOperand(0) == Constant::getNullValue(Bop->getType());
|
ConstantExpr::getZeroValueForNegationExpr(Bop->getType());
|
||||||
else
|
|
||||||
return Bop->getOperand(0) == ConstantFP::get(Bop->getType(), -0.0);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1913,9 +1903,7 @@ CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS,
|
|||||||
assert(Op0Ty == Op1Ty &&
|
assert(Op0Ty == Op1Ty &&
|
||||||
"Both operands to ICmp instruction are not of the same type!");
|
"Both operands to ICmp instruction are not of the same type!");
|
||||||
// Check that the operands are the right type
|
// Check that the operands are the right type
|
||||||
assert(Op0Ty->isInteger() || isa<PointerType>(Op0Ty) ||
|
assert((Op0Ty->isInteger() || isa<PointerType>(Op0Ty)) &&
|
||||||
(isa<PackedType>(Op0Ty) &&
|
|
||||||
cast<PackedType>(Op0Ty)->getElementType()->isInteger()) &&
|
|
||||||
"Invalid operand types for ICmp instruction");
|
"Invalid operand types for ICmp instruction");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1927,8 +1915,7 @@ CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS,
|
|||||||
assert(Op0Ty == Op1Ty &&
|
assert(Op0Ty == Op1Ty &&
|
||||||
"Both operands to FCmp instruction are not of the same type!");
|
"Both operands to FCmp instruction are not of the same type!");
|
||||||
// Check that the operands are the right type
|
// Check that the operands are the right type
|
||||||
assert(Op0Ty->isFloatingPoint() || (isa<PackedType>(Op0Ty) &&
|
assert(Op0Ty->isFloatingPoint() &&
|
||||||
cast<PackedType>(Op0Ty)->getElementType()->isFloatingPoint()) &&
|
|
||||||
"Invalid operand types for FCmp instruction");
|
"Invalid operand types for FCmp instruction");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1948,9 +1935,7 @@ CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS,
|
|||||||
assert(Op0Ty == Op1Ty &&
|
assert(Op0Ty == Op1Ty &&
|
||||||
"Both operands to ICmp instruction are not of the same type!");
|
"Both operands to ICmp instruction are not of the same type!");
|
||||||
// Check that the operands are the right type
|
// Check that the operands are the right type
|
||||||
assert(Op0Ty->isInteger() || isa<PointerType>(Op0Ty) ||
|
assert(Op0Ty->isInteger() || isa<PointerType>(Op0Ty) &&
|
||||||
(isa<PackedType>(Op0Ty) &&
|
|
||||||
cast<PackedType>(Op0Ty)->getElementType()->isInteger()) &&
|
|
||||||
"Invalid operand types for ICmp instruction");
|
"Invalid operand types for ICmp instruction");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1962,8 +1947,7 @@ CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS,
|
|||||||
assert(Op0Ty == Op1Ty &&
|
assert(Op0Ty == Op1Ty &&
|
||||||
"Both operands to FCmp instruction are not of the same type!");
|
"Both operands to FCmp instruction are not of the same type!");
|
||||||
// Check that the operands are the right type
|
// Check that the operands are the right type
|
||||||
assert(Op0Ty->isFloatingPoint() || (isa<PackedType>(Op0Ty) &&
|
assert(Op0Ty->isFloatingPoint() &&
|
||||||
cast<PackedType>(Op0Ty)->getElementType()->isFloatingPoint()) &&
|
|
||||||
"Invalid operand types for FCmp instruction");
|
"Invalid operand types for FCmp instruction");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user