Implement constant propogation of shifts

llvm-svn: 2470
diff --git a/llvm/lib/VMCore/ConstantHandling.cpp b/llvm/lib/VMCore/ConstantHandling.cpp
index 5fd11c3..ee7d43e 100644
--- a/llvm/lib/VMCore/ConstantHandling.cpp
+++ b/llvm/lib/VMCore/ConstantHandling.cpp
@@ -56,6 +56,14 @@
                         const Constant *V2) const { 
     return SubClassName::Rem((const ArgType *)V1, (const ArgType *)V2);  
   }
+  virtual Constant *shl(const Constant *V1, 
+                        const Constant *V2) const { 
+    return SubClassName::Shl((const ArgType *)V1, (const ArgType *)V2);  
+  }
+  virtual Constant *shr(const Constant *V1, 
+                        const Constant *V2) const { 
+    return SubClassName::Shr((const ArgType *)V1, (const ArgType *)V2);  
+  }
 
   virtual ConstantBool *lessthan(const Constant *V1, 
                                  const Constant *V2) const { 
@@ -122,6 +130,12 @@
   inline static Constant *Rem(const ArgType *V1, const ArgType *V2) {
     return 0;
   }
+  inline static Constant *Shl(const ArgType *V1, const ArgType *V2) {
+    return 0;
+  }
+  inline static Constant *Shr(const ArgType *V1, const ArgType *V2) {
+    return 0;
+  }
   inline static ConstantBool *LessThan(const ArgType *V1, const ArgType *V2) {
     return 0;
   }
@@ -337,6 +351,20 @@
                          (BuiltinType)V2->getValue();
     return ConstantClass::get(*Ty, Result);
   }
+
+  inline static Constant *Shl(const ConstantClass *V1,
+                              const ConstantClass *V2) {
+    BuiltinType Result = (BuiltinType)V1->getValue() <<
+                         (BuiltinType)V2->getValue();
+    return ConstantClass::get(*Ty, Result);
+  }
+
+  inline static Constant *Shr(const ConstantClass *V1,
+                              const ConstantClass *V2) {
+    BuiltinType Result = (BuiltinType)V1->getValue() >>
+                         (BuiltinType)V2->getValue();
+    return ConstantClass::get(*Ty, Result);
+  }
 };