mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-27 02:31:09 +00:00
Use ArrayRef in ConstantFoldInstOperands and ConstantFoldCall.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135477 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c8007ab582
commit
1d2f569c34
@ -626,6 +626,8 @@ from the previous release.</p>
|
|||||||
<li><code>ConstantExpr::getIndices</code></li>
|
<li><code>ConstantExpr::getIndices</code></li>
|
||||||
<li><code>ConstantExpr::getInsertElement</code></li>
|
<li><code>ConstantExpr::getInsertElement</code></li>
|
||||||
<li><code>ConstantExpr::getWithOperands</code></li>
|
<li><code>ConstantExpr::getWithOperands</code></li>
|
||||||
|
<li><code>ConstantFoldCall</code> (in <code>llvm/Analysis/ConstantFolding.h</code>)</li>
|
||||||
|
<li><code>ConstantFoldInstOperands</code> (in <code>llvm/Analysis/ConstantFolding.h</code>)</li>
|
||||||
<li><code>ConstantVector::get</code></li>
|
<li><code>ConstantVector::get</code></li>
|
||||||
<li><code>DIBuilder::createComplexVariable</code></li>
|
<li><code>DIBuilder::createComplexVariable</code></li>
|
||||||
<li><code>DIBuilder::getOrCreateArray</code></li>
|
<li><code>DIBuilder::getOrCreateArray</code></li>
|
||||||
|
@ -27,6 +27,8 @@ namespace llvm {
|
|||||||
class TargetData;
|
class TargetData;
|
||||||
class Function;
|
class Function;
|
||||||
class Type;
|
class Type;
|
||||||
|
template<typename T>
|
||||||
|
class ArrayRef;
|
||||||
|
|
||||||
/// ConstantFoldInstruction - Try to constant fold the specified instruction.
|
/// ConstantFoldInstruction - Try to constant fold the specified instruction.
|
||||||
/// If successful, the constant result is returned, if not, null is returned.
|
/// If successful, the constant result is returned, if not, null is returned.
|
||||||
@ -48,7 +50,7 @@ Constant *ConstantFoldConstantExpression(const ConstantExpr *CE,
|
|||||||
/// form.
|
/// form.
|
||||||
///
|
///
|
||||||
Constant *ConstantFoldInstOperands(unsigned Opcode, Type *DestTy,
|
Constant *ConstantFoldInstOperands(unsigned Opcode, Type *DestTy,
|
||||||
Constant *const *Ops, unsigned NumOps,
|
ArrayRef<Constant *> Ops,
|
||||||
const TargetData *TD = 0);
|
const TargetData *TD = 0);
|
||||||
|
|
||||||
/// ConstantFoldCompareInstOperands - Attempt to constant fold a compare
|
/// ConstantFoldCompareInstOperands - Attempt to constant fold a compare
|
||||||
@ -76,7 +78,7 @@ bool canConstantFoldCallTo(const Function *F);
|
|||||||
/// ConstantFoldCall - Attempt to constant fold a call to the specified function
|
/// ConstantFoldCall - Attempt to constant fold a call to the specified function
|
||||||
/// with the specified arguments, returning null if unsuccessful.
|
/// with the specified arguments, returning null if unsuccessful.
|
||||||
Constant *
|
Constant *
|
||||||
ConstantFoldCall(Function *F, Constant *const *Operands, unsigned NumOperands);
|
ConstantFoldCall(Function *F, ArrayRef<Constant *> Operands);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -536,7 +536,7 @@ static Constant *SymbolicallyEvaluateBinop(unsigned Opc, Constant *Op0,
|
|||||||
/// CastGEPIndices - If array indices are not pointer-sized integers,
|
/// CastGEPIndices - If array indices are not pointer-sized integers,
|
||||||
/// explicitly cast them so that they aren't implicitly casted by the
|
/// explicitly cast them so that they aren't implicitly casted by the
|
||||||
/// getelementptr.
|
/// getelementptr.
|
||||||
static Constant *CastGEPIndices(Constant *const *Ops, unsigned NumOps,
|
static Constant *CastGEPIndices(ArrayRef<Constant *> Ops,
|
||||||
Type *ResultTy,
|
Type *ResultTy,
|
||||||
const TargetData *TD) {
|
const TargetData *TD) {
|
||||||
if (!TD) return 0;
|
if (!TD) return 0;
|
||||||
@ -544,10 +544,10 @@ static Constant *CastGEPIndices(Constant *const *Ops, unsigned NumOps,
|
|||||||
|
|
||||||
bool Any = false;
|
bool Any = false;
|
||||||
SmallVector<Constant*, 32> NewIdxs;
|
SmallVector<Constant*, 32> NewIdxs;
|
||||||
for (unsigned i = 1; i != NumOps; ++i) {
|
for (unsigned i = 1, e = Ops.size(); i != e; ++i) {
|
||||||
if ((i == 1 ||
|
if ((i == 1 ||
|
||||||
!isa<StructType>(GetElementPtrInst::getIndexedType(Ops[0]->getType(),
|
!isa<StructType>(GetElementPtrInst::getIndexedType(Ops[0]->getType(),
|
||||||
reinterpret_cast<Value *const *>(Ops+1),
|
Ops.data() + 1,
|
||||||
i-1))) &&
|
i-1))) &&
|
||||||
Ops[i]->getType() != IntPtrTy) {
|
Ops[i]->getType() != IntPtrTy) {
|
||||||
Any = true;
|
Any = true;
|
||||||
@ -571,7 +571,7 @@ static Constant *CastGEPIndices(Constant *const *Ops, unsigned NumOps,
|
|||||||
|
|
||||||
/// SymbolicallyEvaluateGEP - If we can symbolically evaluate the specified GEP
|
/// SymbolicallyEvaluateGEP - If we can symbolically evaluate the specified GEP
|
||||||
/// constant expression, do so.
|
/// constant expression, do so.
|
||||||
static Constant *SymbolicallyEvaluateGEP(Constant *const *Ops, unsigned NumOps,
|
static Constant *SymbolicallyEvaluateGEP(ArrayRef<Constant *> Ops,
|
||||||
Type *ResultTy,
|
Type *ResultTy,
|
||||||
const TargetData *TD) {
|
const TargetData *TD) {
|
||||||
Constant *Ptr = Ops[0];
|
Constant *Ptr = Ops[0];
|
||||||
@ -582,12 +582,12 @@ static Constant *SymbolicallyEvaluateGEP(Constant *const *Ops, unsigned NumOps,
|
|||||||
|
|
||||||
// If this is a constant expr gep that is effectively computing an
|
// If this is a constant expr gep that is effectively computing an
|
||||||
// "offsetof", fold it into 'cast int Size to T*' instead of 'gep 0, 0, 12'
|
// "offsetof", fold it into 'cast int Size to T*' instead of 'gep 0, 0, 12'
|
||||||
for (unsigned i = 1; i != NumOps; ++i)
|
for (unsigned i = 1, e = Ops.size(); i != e; ++i)
|
||||||
if (!isa<ConstantInt>(Ops[i])) {
|
if (!isa<ConstantInt>(Ops[i])) {
|
||||||
|
|
||||||
// If this is "gep i8* Ptr, (sub 0, V)", fold this as:
|
// If this is "gep i8* Ptr, (sub 0, V)", fold this as:
|
||||||
// "inttoptr (sub (ptrtoint Ptr), V)"
|
// "inttoptr (sub (ptrtoint Ptr), V)"
|
||||||
if (NumOps == 2 &&
|
if (Ops.size() == 2 &&
|
||||||
cast<PointerType>(ResultTy)->getElementType()->isIntegerTy(8)) {
|
cast<PointerType>(ResultTy)->getElementType()->isIntegerTy(8)) {
|
||||||
ConstantExpr *CE = dyn_cast<ConstantExpr>(Ops[1]);
|
ConstantExpr *CE = dyn_cast<ConstantExpr>(Ops[1]);
|
||||||
assert((CE == 0 || CE->getType() == IntPtrTy) &&
|
assert((CE == 0 || CE->getType() == IntPtrTy) &&
|
||||||
@ -608,7 +608,8 @@ static Constant *SymbolicallyEvaluateGEP(Constant *const *Ops, unsigned NumOps,
|
|||||||
unsigned BitWidth = TD->getTypeSizeInBits(IntPtrTy);
|
unsigned BitWidth = TD->getTypeSizeInBits(IntPtrTy);
|
||||||
APInt Offset = APInt(BitWidth,
|
APInt Offset = APInt(BitWidth,
|
||||||
TD->getIndexedOffset(Ptr->getType(),
|
TD->getIndexedOffset(Ptr->getType(),
|
||||||
(Value**)Ops+1, NumOps-1));
|
(Value**)Ops.data() + 1,
|
||||||
|
Ops.size() - 1));
|
||||||
Ptr = cast<Constant>(Ptr->stripPointerCasts());
|
Ptr = cast<Constant>(Ptr->stripPointerCasts());
|
||||||
|
|
||||||
// If this is a GEP of a GEP, fold it all into a single GEP.
|
// If this is a GEP of a GEP, fold it all into a single GEP.
|
||||||
@ -778,8 +779,7 @@ Constant *llvm::ConstantFoldInstruction(Instruction *I, const TargetData *TD) {
|
|||||||
cast<Constant>(EVI->getAggregateOperand()),
|
cast<Constant>(EVI->getAggregateOperand()),
|
||||||
EVI->getIndices());
|
EVI->getIndices());
|
||||||
|
|
||||||
return ConstantFoldInstOperands(I->getOpcode(), I->getType(),
|
return ConstantFoldInstOperands(I->getOpcode(), I->getType(), Ops, TD);
|
||||||
Ops.data(), Ops.size(), TD);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ConstantFoldConstantExpression - Attempt to fold the constant expression
|
/// ConstantFoldConstantExpression - Attempt to fold the constant expression
|
||||||
@ -800,8 +800,7 @@ Constant *llvm::ConstantFoldConstantExpression(const ConstantExpr *CE,
|
|||||||
if (CE->isCompare())
|
if (CE->isCompare())
|
||||||
return ConstantFoldCompareInstOperands(CE->getPredicate(), Ops[0], Ops[1],
|
return ConstantFoldCompareInstOperands(CE->getPredicate(), Ops[0], Ops[1],
|
||||||
TD);
|
TD);
|
||||||
return ConstantFoldInstOperands(CE->getOpcode(), CE->getType(),
|
return ConstantFoldInstOperands(CE->getOpcode(), CE->getType(), Ops, TD);
|
||||||
Ops.data(), Ops.size(), TD);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ConstantFoldInstOperands - Attempt to constant fold an instruction with the
|
/// ConstantFoldInstOperands - Attempt to constant fold an instruction with the
|
||||||
@ -815,7 +814,7 @@ Constant *llvm::ConstantFoldConstantExpression(const ConstantExpr *CE,
|
|||||||
/// folding using this function strips this information.
|
/// folding using this function strips this information.
|
||||||
///
|
///
|
||||||
Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, Type *DestTy,
|
Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, Type *DestTy,
|
||||||
Constant* const* Ops, unsigned NumOps,
|
ArrayRef<Constant *> Ops,
|
||||||
const TargetData *TD) {
|
const TargetData *TD) {
|
||||||
// Handle easy binops first.
|
// Handle easy binops first.
|
||||||
if (Instruction::isBinaryOp(Opcode)) {
|
if (Instruction::isBinaryOp(Opcode)) {
|
||||||
@ -831,9 +830,9 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, Type *DestTy,
|
|||||||
case Instruction::ICmp:
|
case Instruction::ICmp:
|
||||||
case Instruction::FCmp: assert(0 && "Invalid for compares");
|
case Instruction::FCmp: assert(0 && "Invalid for compares");
|
||||||
case Instruction::Call:
|
case Instruction::Call:
|
||||||
if (Function *F = dyn_cast<Function>(Ops[NumOps - 1]))
|
if (Function *F = dyn_cast<Function>(Ops.back()))
|
||||||
if (canConstantFoldCallTo(F))
|
if (canConstantFoldCallTo(F))
|
||||||
return ConstantFoldCall(F, Ops, NumOps - 1);
|
return ConstantFoldCall(F, Ops.slice(0, Ops.size() - 1));
|
||||||
return 0;
|
return 0;
|
||||||
case Instruction::PtrToInt:
|
case Instruction::PtrToInt:
|
||||||
// If the input is a inttoptr, eliminate the pair. This requires knowing
|
// If the input is a inttoptr, eliminate the pair. This requires knowing
|
||||||
@ -887,12 +886,13 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, Type *DestTy,
|
|||||||
case Instruction::ShuffleVector:
|
case Instruction::ShuffleVector:
|
||||||
return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2]);
|
return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2]);
|
||||||
case Instruction::GetElementPtr:
|
case Instruction::GetElementPtr:
|
||||||
if (Constant *C = CastGEPIndices(Ops, NumOps, DestTy, TD))
|
if (Constant *C = CastGEPIndices(Ops, DestTy, TD))
|
||||||
return C;
|
return C;
|
||||||
if (Constant *C = SymbolicallyEvaluateGEP(Ops, NumOps, DestTy, TD))
|
if (Constant *C = SymbolicallyEvaluateGEP(Ops, DestTy, TD))
|
||||||
return C;
|
return C;
|
||||||
|
|
||||||
return ConstantExpr::getGetElementPtr(Ops[0], Ops+1, NumOps-1);
|
return ConstantExpr::getGetElementPtr(Ops[0], Ops.data() + 1,
|
||||||
|
Ops.size() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -967,7 +967,7 @@ Constant *llvm::ConstantFoldCompareInstOperands(unsigned Predicate,
|
|||||||
unsigned OpC =
|
unsigned OpC =
|
||||||
Predicate == ICmpInst::ICMP_EQ ? Instruction::And : Instruction::Or;
|
Predicate == ICmpInst::ICMP_EQ ? Instruction::And : Instruction::Or;
|
||||||
Constant *Ops[] = { LHS, RHS };
|
Constant *Ops[] = { LHS, RHS };
|
||||||
return ConstantFoldInstOperands(OpC, LHS->getType(), Ops, 2, TD);
|
return ConstantFoldInstOperands(OpC, LHS->getType(), Ops, TD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1167,13 +1167,12 @@ static Constant *ConstantFoldConvertToInt(ConstantFP *Op, bool roundTowardZero,
|
|||||||
/// ConstantFoldCall - Attempt to constant fold a call to the specified function
|
/// ConstantFoldCall - Attempt to constant fold a call to the specified function
|
||||||
/// with the specified arguments, returning null if unsuccessful.
|
/// with the specified arguments, returning null if unsuccessful.
|
||||||
Constant *
|
Constant *
|
||||||
llvm::ConstantFoldCall(Function *F,
|
llvm::ConstantFoldCall(Function *F, ArrayRef<Constant *> Operands) {
|
||||||
Constant *const *Operands, unsigned NumOperands) {
|
|
||||||
if (!F->hasName()) return 0;
|
if (!F->hasName()) return 0;
|
||||||
StringRef Name = F->getName();
|
StringRef Name = F->getName();
|
||||||
|
|
||||||
Type *Ty = F->getReturnType();
|
Type *Ty = F->getReturnType();
|
||||||
if (NumOperands == 1) {
|
if (Operands.size() == 1) {
|
||||||
if (ConstantFP *Op = dyn_cast<ConstantFP>(Operands[0])) {
|
if (ConstantFP *Op = dyn_cast<ConstantFP>(Operands[0])) {
|
||||||
if (F->getIntrinsicID() == Intrinsic::convert_to_fp16) {
|
if (F->getIntrinsicID() == Intrinsic::convert_to_fp16) {
|
||||||
APFloat Val(Op->getValueAPF());
|
APFloat Val(Op->getValueAPF());
|
||||||
@ -1327,7 +1326,7 @@ llvm::ConstantFoldCall(Function *F,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NumOperands == 2) {
|
if (Operands.size() == 2) {
|
||||||
if (ConstantFP *Op1 = dyn_cast<ConstantFP>(Operands[0])) {
|
if (ConstantFP *Op1 = dyn_cast<ConstantFP>(Operands[0])) {
|
||||||
if (!Ty->isFloatTy() && !Ty->isDoubleTy())
|
if (!Ty->isFloatTy() && !Ty->isDoubleTy())
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -526,7 +526,7 @@ static Value *SimplifyAddInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW,
|
|||||||
if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
|
if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
|
||||||
Constant *Ops[] = { CLHS, CRHS };
|
Constant *Ops[] = { CLHS, CRHS };
|
||||||
return ConstantFoldInstOperands(Instruction::Add, CLHS->getType(),
|
return ConstantFoldInstOperands(Instruction::Add, CLHS->getType(),
|
||||||
Ops, 2, TD);
|
Ops, TD);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Canonicalize the constant to the RHS.
|
// Canonicalize the constant to the RHS.
|
||||||
@ -595,7 +595,7 @@ static Value *SimplifySubInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW,
|
|||||||
if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
|
if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
|
||||||
Constant *Ops[] = { CLHS, CRHS };
|
Constant *Ops[] = { CLHS, CRHS };
|
||||||
return ConstantFoldInstOperands(Instruction::Sub, CLHS->getType(),
|
return ConstantFoldInstOperands(Instruction::Sub, CLHS->getType(),
|
||||||
Ops, 2, TD);
|
Ops, TD);
|
||||||
}
|
}
|
||||||
|
|
||||||
// X - undef -> undef
|
// X - undef -> undef
|
||||||
@ -715,7 +715,7 @@ static Value *SimplifyMulInst(Value *Op0, Value *Op1, const TargetData *TD,
|
|||||||
if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
|
if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
|
||||||
Constant *Ops[] = { CLHS, CRHS };
|
Constant *Ops[] = { CLHS, CRHS };
|
||||||
return ConstantFoldInstOperands(Instruction::Mul, CLHS->getType(),
|
return ConstantFoldInstOperands(Instruction::Mul, CLHS->getType(),
|
||||||
Ops, 2, TD);
|
Ops, TD);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Canonicalize the constant to the RHS.
|
// Canonicalize the constant to the RHS.
|
||||||
@ -788,7 +788,7 @@ static Value *SimplifyDiv(Instruction::BinaryOps Opcode, Value *Op0, Value *Op1,
|
|||||||
if (Constant *C0 = dyn_cast<Constant>(Op0)) {
|
if (Constant *C0 = dyn_cast<Constant>(Op0)) {
|
||||||
if (Constant *C1 = dyn_cast<Constant>(Op1)) {
|
if (Constant *C1 = dyn_cast<Constant>(Op1)) {
|
||||||
Constant *Ops[] = { C0, C1 };
|
Constant *Ops[] = { C0, C1 };
|
||||||
return ConstantFoldInstOperands(Opcode, C0->getType(), Ops, 2, TD);
|
return ConstantFoldInstOperands(Opcode, C0->getType(), Ops, TD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -909,7 +909,7 @@ static Value *SimplifyRem(Instruction::BinaryOps Opcode, Value *Op0, Value *Op1,
|
|||||||
if (Constant *C0 = dyn_cast<Constant>(Op0)) {
|
if (Constant *C0 = dyn_cast<Constant>(Op0)) {
|
||||||
if (Constant *C1 = dyn_cast<Constant>(Op1)) {
|
if (Constant *C1 = dyn_cast<Constant>(Op1)) {
|
||||||
Constant *Ops[] = { C0, C1 };
|
Constant *Ops[] = { C0, C1 };
|
||||||
return ConstantFoldInstOperands(Opcode, C0->getType(), Ops, 2, TD);
|
return ConstantFoldInstOperands(Opcode, C0->getType(), Ops, TD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1012,7 +1012,7 @@ static Value *SimplifyShift(unsigned Opcode, Value *Op0, Value *Op1,
|
|||||||
if (Constant *C0 = dyn_cast<Constant>(Op0)) {
|
if (Constant *C0 = dyn_cast<Constant>(Op0)) {
|
||||||
if (Constant *C1 = dyn_cast<Constant>(Op1)) {
|
if (Constant *C1 = dyn_cast<Constant>(Op1)) {
|
||||||
Constant *Ops[] = { C0, C1 };
|
Constant *Ops[] = { C0, C1 };
|
||||||
return ConstantFoldInstOperands(Opcode, C0->getType(), Ops, 2, TD);
|
return ConstantFoldInstOperands(Opcode, C0->getType(), Ops, TD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1138,7 +1138,7 @@ static Value *SimplifyAndInst(Value *Op0, Value *Op1, const TargetData *TD,
|
|||||||
if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
|
if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
|
||||||
Constant *Ops[] = { CLHS, CRHS };
|
Constant *Ops[] = { CLHS, CRHS };
|
||||||
return ConstantFoldInstOperands(Instruction::And, CLHS->getType(),
|
return ConstantFoldInstOperands(Instruction::And, CLHS->getType(),
|
||||||
Ops, 2, TD);
|
Ops, TD);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Canonicalize the constant to the RHS.
|
// Canonicalize the constant to the RHS.
|
||||||
@ -1227,7 +1227,7 @@ static Value *SimplifyOrInst(Value *Op0, Value *Op1, const TargetData *TD,
|
|||||||
if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
|
if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
|
||||||
Constant *Ops[] = { CLHS, CRHS };
|
Constant *Ops[] = { CLHS, CRHS };
|
||||||
return ConstantFoldInstOperands(Instruction::Or, CLHS->getType(),
|
return ConstantFoldInstOperands(Instruction::Or, CLHS->getType(),
|
||||||
Ops, 2, TD);
|
Ops, TD);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Canonicalize the constant to the RHS.
|
// Canonicalize the constant to the RHS.
|
||||||
@ -1321,7 +1321,7 @@ static Value *SimplifyXorInst(Value *Op0, Value *Op1, const TargetData *TD,
|
|||||||
if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
|
if (Constant *CRHS = dyn_cast<Constant>(Op1)) {
|
||||||
Constant *Ops[] = { CLHS, CRHS };
|
Constant *Ops[] = { CLHS, CRHS };
|
||||||
return ConstantFoldInstOperands(Instruction::Xor, CLHS->getType(),
|
return ConstantFoldInstOperands(Instruction::Xor, CLHS->getType(),
|
||||||
Ops, 2, TD);
|
Ops, TD);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Canonicalize the constant to the RHS.
|
// Canonicalize the constant to the RHS.
|
||||||
@ -2328,7 +2328,7 @@ static Value *SimplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS,
|
|||||||
if (Constant *CLHS = dyn_cast<Constant>(LHS))
|
if (Constant *CLHS = dyn_cast<Constant>(LHS))
|
||||||
if (Constant *CRHS = dyn_cast<Constant>(RHS)) {
|
if (Constant *CRHS = dyn_cast<Constant>(RHS)) {
|
||||||
Constant *COps[] = {CLHS, CRHS};
|
Constant *COps[] = {CLHS, CRHS};
|
||||||
return ConstantFoldInstOperands(Opcode, LHS->getType(), COps, 2, TD);
|
return ConstantFoldInstOperands(Opcode, LHS->getType(), COps, TD);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the operation is associative, try some generic simplifications.
|
// If the operation is associative, try some generic simplifications.
|
||||||
|
@ -4492,8 +4492,7 @@ static Constant *EvaluateExpression(Value *V, Constant *PHIVal,
|
|||||||
if (const CmpInst *CI = dyn_cast<CmpInst>(I))
|
if (const CmpInst *CI = dyn_cast<CmpInst>(I))
|
||||||
return ConstantFoldCompareInstOperands(CI->getPredicate(), Operands[0],
|
return ConstantFoldCompareInstOperands(CI->getPredicate(), Operands[0],
|
||||||
Operands[1], TD);
|
Operands[1], TD);
|
||||||
return ConstantFoldInstOperands(I->getOpcode(), I->getType(),
|
return ConstantFoldInstOperands(I->getOpcode(), I->getType(), Operands, TD);
|
||||||
&Operands[0], Operands.size(), TD);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getConstantEvolutionLoopExitValue - If we know that the specified Phi is
|
/// getConstantEvolutionLoopExitValue - If we know that the specified Phi is
|
||||||
@ -4703,7 +4702,7 @@ const SCEV *ScalarEvolution::computeSCEVAtScope(const SCEV *V, const Loop *L) {
|
|||||||
Operands[0], Operands[1], TD);
|
Operands[0], Operands[1], TD);
|
||||||
else
|
else
|
||||||
C = ConstantFoldInstOperands(I->getOpcode(), I->getType(),
|
C = ConstantFoldInstOperands(I->getOpcode(), I->getType(),
|
||||||
&Operands[0], Operands.size(), TD);
|
Operands, TD);
|
||||||
if (!C) return V;
|
if (!C) return V;
|
||||||
return getSCEV(C);
|
return getSCEV(C);
|
||||||
}
|
}
|
||||||
|
@ -2465,8 +2465,7 @@ static bool EvaluateFunction(Function *F, Constant *&RetVal,
|
|||||||
|
|
||||||
if (Callee->isDeclaration()) {
|
if (Callee->isDeclaration()) {
|
||||||
// If this is a function we can constant fold, do it.
|
// If this is a function we can constant fold, do it.
|
||||||
if (Constant *C = ConstantFoldCall(Callee, Formals.data(),
|
if (Constant *C = ConstantFoldCall(Callee, Formals)) {
|
||||||
Formals.size())) {
|
|
||||||
InstResult = C;
|
InstResult = C;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -325,7 +325,7 @@ static Value *SimplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
|
|||||||
// All operands were constants, fold it.
|
// All operands were constants, fold it.
|
||||||
if (ConstOps.size() == I->getNumOperands())
|
if (ConstOps.size() == I->getNumOperands())
|
||||||
return ConstantFoldInstOperands(I->getOpcode(), I->getType(),
|
return ConstantFoldInstOperands(I->getOpcode(), I->getType(),
|
||||||
ConstOps.data(), ConstOps.size(), TD);
|
ConstOps, TD);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1278,7 +1278,7 @@ CallOverdefined:
|
|||||||
|
|
||||||
// If we can constant fold this, mark the result of the call as a
|
// If we can constant fold this, mark the result of the call as a
|
||||||
// constant.
|
// constant.
|
||||||
if (Constant *C = ConstantFoldCall(F, Operands.data(), Operands.size()))
|
if (Constant *C = ConstantFoldCall(F, Operands))
|
||||||
return markConstant(I, C);
|
return markConstant(I, C);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,8 +338,7 @@ ConstantFoldMappedInstruction(const Instruction *I) {
|
|||||||
return ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(),
|
return ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(),
|
||||||
CE);
|
CE);
|
||||||
|
|
||||||
return ConstantFoldInstOperands(I->getOpcode(), I->getType(), &Ops[0],
|
return ConstantFoldInstOperands(I->getOpcode(), I->getType(), Ops, TD);
|
||||||
Ops.size(), TD);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// CloneAndPruneFunctionInto - This works exactly like CloneFunctionInto,
|
/// CloneAndPruneFunctionInto - This works exactly like CloneFunctionInto,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user