Add a new helper function to IVUsers for returning the "canonical"
authorDan Gohman <gohman@apple.com>
Tue, 19 Jan 2010 21:55:32 +0000 (21:55 +0000)
committerDan Gohman <gohman@apple.com>
Tue, 19 Jan 2010 21:55:32 +0000 (21:55 +0000)
form of an expression. This is the expression without the
post-increment adjustment made, which is useful in determining
which registers will be used by the expansion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93921 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/IVUsers.h
lib/Analysis/IVUsers.cpp

index fcd9caa61f2c9a5b80c35f13bad7d3ed558ae61c..50f7d45e19af119564a23c1a0d8735c7c8d98424 100644 (file)
@@ -212,6 +212,11 @@ public:
   /// value of the OperandValToReplace of the given IVStrideUse.
   const SCEV *getReplacementExpr(const IVStrideUse &U) const;
 
+  /// getCanonicalExpr - Return a SCEV expression which computes the
+  /// value of the SCEV of the given IVStrideUse, ignoring the 
+  /// isUseOfPostIncrementedValue flag.
+  const SCEV *getCanonicalExpr(const IVStrideUse &U) const;
+
   void print(raw_ostream &OS, const Module* = 0) const;
 
   /// dump - This method is used for debugging.
index 26c0c9e4ba8fa2a19ca2b8ec2e19688bebcfeff0..92f00273a2cb86dc29af8c949495a392f3055750 100644 (file)
@@ -333,6 +333,19 @@ const SCEV *IVUsers::getReplacementExpr(const IVStrideUse &U) const {
   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;
+}
+
 void IVUsers::print(raw_ostream &OS, const Module *M) const {
   OS << "IV Users for loop ";
   WriteAsOperand(OS, L->getHeader(), false);