whitespace

llvm-svn: 127340
This commit is contained in:
Andrew Trick 2011-03-09 17:23:39 +00:00
parent 4cf03850a2
commit de565b0456

View File

@ -203,7 +203,7 @@ void SCEV::print(raw_ostream &OS) const {
OS << "alignof(" << *AllocTy << ")"; OS << "alignof(" << *AllocTy << ")";
return; return;
} }
const Type *CTy; const Type *CTy;
Constant *FieldNo; Constant *FieldNo;
if (U->isOffsetOf(CTy, FieldNo)) { if (U->isOffsetOf(CTy, FieldNo)) {
@ -212,7 +212,7 @@ void SCEV::print(raw_ostream &OS) const {
OS << ")"; OS << ")";
return; return;
} }
// Otherwise just print it normally. // Otherwise just print it normally.
WriteAsOperand(OS, U->getValue(), false); WriteAsOperand(OS, U->getValue(), false);
return; return;
@ -2783,7 +2783,7 @@ const SCEV *ScalarEvolution::createNodeForPHI(PHINode *PN) {
HasNUW = true; HasNUW = true;
if (OBO->hasNoSignedWrap()) if (OBO->hasNoSignedWrap())
HasNSW = true; HasNSW = true;
} else if (const GEPOperator *GEP = } else if (const GEPOperator *GEP =
dyn_cast<GEPOperator>(BEValueV)) { dyn_cast<GEPOperator>(BEValueV)) {
// If the increment is a GEP, then we know it won't perform a // If the increment is a GEP, then we know it won't perform a
// signed overflow, because the address space cannot be // signed overflow, because the address space cannot be
@ -2798,7 +2798,7 @@ const SCEV *ScalarEvolution::createNodeForPHI(PHINode *PN) {
// //
// This is a highly theoretical concern though, and this is good // This is a highly theoretical concern though, and this is good
// enough for all cases we know of at this point. :) // enough for all cases we know of at this point. :)
// //
HasNSW |= GEP->isInBounds(); HasNSW |= GEP->isInBounds();
} }
@ -3349,7 +3349,7 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) {
SmallVector<const SCEV *, 4> MulOps; SmallVector<const SCEV *, 4> MulOps;
MulOps.push_back(getSCEV(U->getOperand(1))); MulOps.push_back(getSCEV(U->getOperand(1)));
for (Value *Op = U->getOperand(0); for (Value *Op = U->getOperand(0);
Op->getValueID() == Instruction::Mul + Value::InstructionVal; Op->getValueID() == Instruction::Mul + Value::InstructionVal;
Op = U->getOperand(0)) { Op = U->getOperand(0)) {
U = cast<Operator>(Op); U = cast<Operator>(Op);
MulOps.push_back(getSCEV(U->getOperand(1))); MulOps.push_back(getSCEV(U->getOperand(1)));
@ -4025,11 +4025,11 @@ ScalarEvolution::ComputeBackedgeTakenCountFromExitCond(const Loop *L,
static const SCEVAddRecExpr * static const SCEVAddRecExpr *
isSimpleUnwrappingAddRec(const SCEV *S, const Loop *L) { isSimpleUnwrappingAddRec(const SCEV *S, const Loop *L) {
const SCEVAddRecExpr *SA = dyn_cast<SCEVAddRecExpr>(S); const SCEVAddRecExpr *SA = dyn_cast<SCEVAddRecExpr>(S);
// The SCEV must be an addrec of this loop. // The SCEV must be an addrec of this loop.
if (!SA || SA->getLoop() != L || !SA->isAffine()) if (!SA || SA->getLoop() != L || !SA->isAffine())
return 0; return 0;
// The SCEV must be known to not wrap in some way to be interesting. // The SCEV must be known to not wrap in some way to be interesting.
if (!SA->hasNoUnsignedWrap() && !SA->hasNoSignedWrap()) if (!SA->hasNoUnsignedWrap() && !SA->hasNoSignedWrap())
return 0; return 0;
@ -4064,24 +4064,24 @@ static const SCEV *getMinusSCEVForExitTest(const SCEV *LHS, const SCEV *RHS,
// See if LHS and RHS are addrec's we can handle. // See if LHS and RHS are addrec's we can handle.
const SCEVAddRecExpr *LHSA = isSimpleUnwrappingAddRec(LHS, L); const SCEVAddRecExpr *LHSA = isSimpleUnwrappingAddRec(LHS, L);
const SCEVAddRecExpr *RHSA = isSimpleUnwrappingAddRec(RHS, L); const SCEVAddRecExpr *RHSA = isSimpleUnwrappingAddRec(RHS, L);
// If neither addrec is interesting, just return a minus. // If neither addrec is interesting, just return a minus.
if (RHSA == 0 && LHSA == 0) if (RHSA == 0 && LHSA == 0)
return SE.getMinusSCEV(LHS, RHS); return SE.getMinusSCEV(LHS, RHS);
// If only one of LHS and RHS are an AddRec of this loop, make sure it is LHS. // If only one of LHS and RHS are an AddRec of this loop, make sure it is LHS.
if (RHSA && LHSA == 0) { if (RHSA && LHSA == 0) {
// Safe because a-b === b-a for comparisons against zero. // Safe because a-b === b-a for comparisons against zero.
std::swap(LHS, RHS); std::swap(LHS, RHS);
std::swap(LHSA, RHSA); std::swap(LHSA, RHSA);
} }
// Handle the case when only one is advancing in a non-overflowing way. // Handle the case when only one is advancing in a non-overflowing way.
if (RHSA == 0) { if (RHSA == 0) {
// If RHS is loop varying, then we can't predict when LHS will cross it. // If RHS is loop varying, then we can't predict when LHS will cross it.
if (!SE.isLoopInvariant(RHS, L)) if (!SE.isLoopInvariant(RHS, L))
return SE.getMinusSCEV(LHS, RHS); return SE.getMinusSCEV(LHS, RHS);
// If LHS has a positive stride, then we compute RHS-LHS, because the loop // If LHS has a positive stride, then we compute RHS-LHS, because the loop
// is counting up until it crosses RHS (which must be larger than LHS). If // is counting up until it crosses RHS (which must be larger than LHS). If
// it is negative, we compute LHS-RHS because we're counting down to RHS. // it is negative, we compute LHS-RHS because we're counting down to RHS.
@ -4092,19 +4092,19 @@ static const SCEV *getMinusSCEVForExitTest(const SCEV *LHS, const SCEV *RHS,
return SE.getMinusSCEV(RHS, LHS, true /*HasNUW*/); return SE.getMinusSCEV(RHS, LHS, true /*HasNUW*/);
} }
// If both LHS and RHS are interesting, we have something like: // If both LHS and RHS are interesting, we have something like:
// a+i*4 != b+i*8. // a+i*4 != b+i*8.
const ConstantInt *LHSStride = const ConstantInt *LHSStride =
cast<SCEVConstant>(LHSA->getOperand(1))->getValue(); cast<SCEVConstant>(LHSA->getOperand(1))->getValue();
const ConstantInt *RHSStride = const ConstantInt *RHSStride =
cast<SCEVConstant>(RHSA->getOperand(1))->getValue(); cast<SCEVConstant>(RHSA->getOperand(1))->getValue();
// If the strides are equal, then this is just a (complex) loop invariant // If the strides are equal, then this is just a (complex) loop invariant
// comparison of a and b. // comparison of a and b.
if (LHSStride == RHSStride) if (LHSStride == RHSStride)
return SE.getMinusSCEV(LHSA->getStart(), RHSA->getStart()); return SE.getMinusSCEV(LHSA->getStart(), RHSA->getStart());
// If the signs of the strides differ, then the negative stride is counting // If the signs of the strides differ, then the negative stride is counting
// down to the positive stride. // down to the positive stride.
if (LHSStride->getValue().isNegative() != RHSStride->getValue().isNegative()){ if (LHSStride->getValue().isNegative() != RHSStride->getValue().isNegative()){
@ -4117,7 +4117,7 @@ static const SCEV *getMinusSCEVForExitTest(const SCEV *LHS, const SCEV *RHS,
if (RHSStride->getValue().slt(LHSStride->getValue())) if (RHSStride->getValue().slt(LHSStride->getValue()))
std::swap(LHS, RHS); std::swap(LHS, RHS);
} }
return SE.getMinusSCEV(LHS, RHS, true /*HasNUW*/); return SE.getMinusSCEV(LHS, RHS, true /*HasNUW*/);
} }
@ -4903,7 +4903,7 @@ ScalarEvolution::HowFarToZero(const SCEV *V, const Loop *L) {
R2->getValue()))) { R2->getValue()))) {
if (CB->getZExtValue() == false) if (CB->getZExtValue() == false)
std::swap(R1, R2); // R1 is the minimum root now. std::swap(R1, R2); // R1 is the minimum root now.
// We can only use this value if the chrec ends up with an exact zero // We can only use this value if the chrec ends up with an exact zero
// value at this index. When solving for "X*X != 5", for example, we // value at this index. When solving for "X*X != 5", for example, we
// should not accept a root of 2. // should not accept a root of 2.
@ -4942,7 +4942,7 @@ ScalarEvolution::HowFarToZero(const SCEV *V, const Loop *L) {
if (AddRec->hasNoUnsignedWrap()) if (AddRec->hasNoUnsignedWrap())
// FIXME: We really want an "isexact" bit for udiv. // FIXME: We really want an "isexact" bit for udiv.
return getUDivExpr(Start, getNegativeSCEV(Step)); return getUDivExpr(Start, getNegativeSCEV(Step));
// For now we handle only constant steps. // For now we handle only constant steps.
const SCEVConstant *StepC = dyn_cast<SCEVConstant>(Step); const SCEVConstant *StepC = dyn_cast<SCEVConstant>(Step);
if (StepC == 0) if (StepC == 0)
@ -4951,7 +4951,7 @@ ScalarEvolution::HowFarToZero(const SCEV *V, const Loop *L) {
// First, handle unitary steps. // First, handle unitary steps.
if (StepC->getValue()->equalsInt(1)) // 1*N = -Start (mod 2^BW), so: if (StepC->getValue()->equalsInt(1)) // 1*N = -Start (mod 2^BW), so:
return getNegativeSCEV(Start); // N = -Start (as unsigned) return getNegativeSCEV(Start); // N = -Start (as unsigned)
if (StepC->getValue()->isAllOnesValue()) // -1*N = -Start (mod 2^BW), so: if (StepC->getValue()->isAllOnesValue()) // -1*N = -Start (mod 2^BW), so:
return Start; // N = Start (as unsigned) return Start; // N = Start (as unsigned)