Implement hasComputableLoopEvolution for Add, Mul, and Trunc operators,
authorDan Gohman <gohman@apple.com>
Fri, 13 Aug 2010 20:03:15 +0000 (20:03 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 13 Aug 2010 20:03:15 +0000 (20:03 +0000)
since they can support trivial implementations. This avoids potentially
expensive traversals of the operands.

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

include/llvm/Analysis/ScalarEvolutionExpressions.h

index 3e846e1be8307c0eab9a076d0dbc96f8fb811219..dca62727324823be85182b190fda8f4a4c28817f 100644 (file)
@@ -126,6 +126,12 @@ namespace llvm {
   public:
     virtual void print(raw_ostream &OS) const;
 
+    virtual bool hasComputableLoopEvolution(const Loop *QL) const {
+      // Not computable. A truncate of an addrec is always folded into
+      // the addrec.
+      return false;
+    }
+
     /// Methods for support type inquiry through isa, cast, and dyn_cast:
     static inline bool classof(const SCEVTruncateExpr *S) { return true; }
     static inline bool classof(const SCEV *S) {
@@ -294,6 +300,12 @@ namespace llvm {
     }
 
   public:
+    virtual bool hasComputableLoopEvolution(const Loop *QL) const {
+      // Not computable. An add of an addrec is always folded into the addrec
+      // if the other operands are loop-variant or loop-computable.
+      return false;
+    }
+
     virtual const char *getOperationStr() const { return " + "; }
 
     virtual const Type *getType() const {
@@ -322,6 +334,12 @@ namespace llvm {
     }
 
   public:
+    virtual bool hasComputableLoopEvolution(const Loop *QL) const {
+      // Not computable. A mul of an addrec is always folded into the addrec
+      // if the other operands are loop-variant or loop-computable.
+      return false;
+    }
+
     virtual const char *getOperationStr() const { return " * "; }
 
     /// Methods for support type inquiry through isa, cast, and dyn_cast: