// If there is no immediate value, skip the next part.
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(Imm))
// If there is no immediate value, skip the next part.
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(Imm))
- if (SC->getValue()->isNullValue())
+ if (SC->getValue()->isZero())
return Rewriter.expandCodeFor(NewBase, BaseInsertPt,
OperandValToReplace->getType());
return Rewriter.expandCodeFor(NewBase, BaseInsertPt,
OperandValToReplace->getType());
SeparateSubExprs(SubExprs, SARE->getOperand(0));
}
} else if (!isa<SCEVConstant>(Expr) ||
SeparateSubExprs(SubExprs, SARE->getOperand(0));
}
} else if (!isa<SCEVConstant>(Expr) ||
- !cast<SCEVConstant>(Expr)->getValue()->isNullValue()) {
+ !cast<SCEVConstant>(Expr)->getValue()->isZero()) {
// Do not add zero.
SubExprs.push_back(Expr);
}
// Do not add zero.
SubExprs.push_back(Expr);
}
///
static bool isZero(SCEVHandle &V) {
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(V))
///
static bool isZero(SCEVHandle &V) {
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(V))
- return SC->getValue()->getZExtValue() == 0;
+ return SC->getValue()->isZero();
if (!TLI) return 0;
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(Stride)) {
if (!TLI) return 0;
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(Stride)) {
- int64_t SInt = SC->getValue()->getSExtValue();
- if (SInt == 1) return 0;
+ APInt SInt(SC->getValue()->getValue());
+ if (SInt == 1)
+ return 0;
for (TargetLowering::legal_am_scale_iterator
I = TLI->legal_am_scale_begin(), E = TLI->legal_am_scale_end();
I != E; ++I) {
for (TargetLowering::legal_am_scale_iterator
I = TLI->legal_am_scale_begin(), E = TLI->legal_am_scale_end();
I != E; ++I) {
- unsigned Scale = *I;
- if (unsigned(abs(SInt)) < Scale || (SInt % Scale) != 0)
+ APInt Scale(SInt.getBitWidth(), *I);
+ if (SInt.abs().ult(Scale) || SInt.srem(Scale) != 0)
continue;
std::map<SCEVHandle, IVsOfOneStride>::iterator SI =
continue;
std::map<SCEVHandle, IVsOfOneStride>::iterator SI =
- IVsByStride.find(SCEVUnknown::getIntegerSCEV(SInt/Scale, UIntPtrTy));
+ IVsByStride.find(SCEVUnknown::getIntegerSCEV(SInt.sdiv(Scale)));
if (SI == IVsByStride.end())
continue;
for (std::vector<IVExpr>::iterator II = SI->second.IVs.begin(),
if (SI == IVsByStride.end())
continue;
for (std::vector<IVExpr>::iterator II = SI->second.IVs.begin(),
// Only reuse previous IV if it would not require a type conversion.
if (isZero(II->Base) && II->Base->getType() == Ty) {
IV = *II;
// Only reuse previous IV if it would not require a type conversion.
if (isZero(II->Base) && II->Base->getType() == Ty) {
IV = *II;
+ return Scale.getZExtValue();
// are reusing an IV, it has not been used to initialize the PHI node.
// Add it to the expression used to rewrite the uses.
if (!isa<ConstantInt>(CommonBaseV) ||
// are reusing an IV, it has not been used to initialize the PHI node.
// Add it to the expression used to rewrite the uses.
if (!isa<ConstantInt>(CommonBaseV) ||
- !cast<ConstantInt>(CommonBaseV)->isNullValue())
+ !cast<ConstantInt>(CommonBaseV)->isZero())
RewriteExpr = SCEVAddExpr::get(RewriteExpr,
SCEVUnknown::get(CommonBaseV));
}
// Now that we know what we need to do, insert code before User for the
// immediate and any loop-variant expressions.
RewriteExpr = SCEVAddExpr::get(RewriteExpr,
SCEVUnknown::get(CommonBaseV));
}
// Now that we know what we need to do, insert code before User for the
// immediate and any loop-variant expressions.
- if (!isa<ConstantInt>(BaseV) || !cast<ConstantInt>(BaseV)->isNullValue())
+ if (!isa<ConstantInt>(BaseV) || !cast<ConstantInt>(BaseV)->isZero())
// Add BaseV to the PHI value if needed.
RewriteExpr = SCEVAddExpr::get(RewriteExpr, SCEVUnknown::get(BaseV));
// Add BaseV to the PHI value if needed.
RewriteExpr = SCEVAddExpr::get(RewriteExpr, SCEVUnknown::get(BaseV));
cast<BinaryOperator>(I)->swapOperands();
if (ConstantInt *CB = dyn_cast<ConstantInt>(I->getOperand(1)))
if (CB->getType() == Type::Int1Ty) {
cast<BinaryOperator>(I)->swapOperands();
if (ConstantInt *CB = dyn_cast<ConstantInt>(I->getOperand(1)))
if (CB->getType() == Type::Int1Ty) {
- if (CB->getZExtValue()) // X & 1 -> X
+ if (CB->isOne()) // X & 1 -> X
ReplaceUsesOfWith(I, I->getOperand(0), Worklist);
else // X & 0 -> 0
ReplaceUsesOfWith(I, I->getOperand(1), Worklist);
ReplaceUsesOfWith(I, I->getOperand(0), Worklist);
else // X & 0 -> 0
ReplaceUsesOfWith(I, I->getOperand(1), Worklist);
cast<BinaryOperator>(I)->swapOperands();
if (ConstantInt *CB = dyn_cast<ConstantInt>(I->getOperand(1)))
if (CB->getType() == Type::Int1Ty) {
cast<BinaryOperator>(I)->swapOperands();
if (ConstantInt *CB = dyn_cast<ConstantInt>(I->getOperand(1)))
if (CB->getType() == Type::Int1Ty) {
- if (CB->getZExtValue()) // X | 1 -> 1
+ if (CB->isOne()) // X | 1 -> 1
ReplaceUsesOfWith(I, I->getOperand(1), Worklist);
else // X | 0 -> X
ReplaceUsesOfWith(I, I->getOperand(0), Worklist);
ReplaceUsesOfWith(I, I->getOperand(1), Worklist);
else // X | 0 -> X
ReplaceUsesOfWith(I, I->getOperand(0), Worklist);