summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-07-20 19:15:36 +0000
committerChris Lattner <sabre@nondot.org>2001-07-20 19:15:36 +0000
commitb5bcbc3bef1f81fe600ef1b2be919d48e19dbd33 (patch)
treedb029d66518cfaef73660c430f9f1f0a6d4c8e4f /lib
parent622f740a7dcf0b3520244e58b2233898fd4a46e4 (diff)
downloadllvm-b5bcbc3bef1f81fe600ef1b2be919d48e19dbd33.tar.gz
llvm-b5bcbc3bef1f81fe600ef1b2be919d48e19dbd33.tar.bz2
llvm-b5bcbc3bef1f81fe600ef1b2be919d48e19dbd33.tar.xz
Add support for constant propogation of multiplies
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/VMCore/ConstantFold.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index e0a4ffbfb0..e573c4b82b 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -42,6 +42,11 @@ class TemplateRules : public ConstRules {
return SubClassName::Sub((const ArgType *)V1, (const ArgType *)V2);
}
+ virtual ConstPoolVal *mul(const ConstPoolVal *V1,
+ const ConstPoolVal *V2) const {
+ return SubClassName::Mul((const ArgType *)V1, (const ArgType *)V2);
+ }
+
virtual ConstPoolBool *lessthan(const ConstPoolVal *V1,
const ConstPoolVal *V2) const {
return SubClassName::LessThan((const ArgType *)V1, (const ArgType *)V2);
@@ -56,11 +61,12 @@ class TemplateRules : public ConstRules {
inline static ConstPoolVal *Add(const ArgType *V1, const ArgType *V2) {
return 0;
}
-
inline static ConstPoolVal *Sub(const ArgType *V1, const ArgType *V2) {
return 0;
}
-
+ inline static ConstPoolVal *Mul(const ArgType *V1, const ArgType *V2) {
+ return 0;
+ }
inline static ConstPoolBool *LessThan(const ArgType *V1, const ArgType *V2) {
return 0;
}
@@ -138,6 +144,13 @@ struct DirectRules
return new ConstPoolClass(*Ty, Result);
}
+ inline static ConstPoolVal *Mul(const ConstPoolClass *V1,
+ const ConstPoolClass *V2) {
+ BuiltinType Result = (BuiltinType)V1->getValue() *
+ (BuiltinType)V2->getValue();
+ return new ConstPoolClass(*Ty, Result);
+ }
+
inline static ConstPoolBool *LessThan(const ConstPoolClass *V1,
const ConstPoolClass *V2) {
bool Result = (BuiltinType)V1->getValue() < (BuiltinType)V2->getValue();