if (!AddRecStride->properlyDominates(Header, DT))
return false;
- DEBUG(dbgs() << "[" << L->getHeader()->getName()
- << "] Variable stride: " << *AddRec << "\n");
+ DEBUG(dbgs() << "[";
+ WriteAsOperand(dbgs(), L->getHeader(), /*PrintType=*/false);
+ dbgs() << "] Variable stride: " << *AddRec << "\n");
}
Stride = AddRecStride;
// the actual replacement value.
if (U.isUseOfPostIncrementedValue())
RetVal = SE->getAddExpr(RetVal, U.getParent()->Stride);
- // Evaluate the expression out of the loop, if possible.
- if (!L->contains(U.getUser())) {
- const SCEV *ExitVal = SE->getSCEVAtScope(RetVal, L->getParentLoop());
- if (ExitVal->isLoopInvariant(L))
- RetVal = ExitVal;
- }
+ return RetVal;
+}
+
+/// getCanonicalExpr - Return a SCEV expression which computes the
+/// value of the SCEV of the given IVStrideUse, ignoring the
+/// isUseOfPostIncrementedValue flag.
+const SCEV *IVUsers::getCanonicalExpr(const IVStrideUse &U) const {
+ // Start with zero.
+ const SCEV *RetVal = SE->getIntegerSCEV(0, U.getParent()->Stride->getType());
+ // Create the basic add recurrence.
+ RetVal = SE->getAddRecExpr(RetVal, U.getParent()->Stride, L);
+ // Add the offset in a separate step, because it may be loop-variant.
+ RetVal = SE->getAddExpr(RetVal, U.getOffset());
return RetVal;
}
Parent->Users.erase(this);
// this now dangles!
}
+
+void IVUsersOfOneStride::print(raw_ostream &OS) const {
+ OS << "IV Users of one stride:\n";
+
+ if (Stride)
+ OS << " Stride: " << *Stride << '\n';
+
+ OS << " Users:\n";
+
+ unsigned Count = 1;
+
+ for (ilist<IVStrideUse>::const_iterator
+ I = Users.begin(), E = Users.end(); I != E; ++I) {
+ const IVStrideUse &SU = *I;
+ OS << " " << Count++ << '\n';
+ OS << " Offset: " << *SU.getOffset() << '\n';
+ OS << " Instr: " << *SU << '\n';
+ }
+}
+
+void IVUsersOfOneStride::dump() const {
+ print(dbgs());
+}