diff options
author | Chris Lattner <sabre@nondot.org> | 2004-03-12 05:53:32 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-03-12 05:53:32 +0000 |
commit | e97148628f8a52fff1752937f6f49945bbe9937b (patch) | |
tree | abddde6779dd10f0aa2a676fbff595ace2b77e37 /lib/VMCore/ConstantFold.cpp | |
parent | cfdd148972c049291ee6f24f3201a573d9ac5809 (diff) |
Teach the constant folder how to do select instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12321 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/ConstantFold.cpp')
-rw-r--r-- | lib/VMCore/ConstantFold.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 5f7e0ef1b8..db21bd3d78 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -582,6 +582,17 @@ Constant *llvm::ConstantFoldCastInstruction(const Constant *V, } } +Constant *llvm::ConstantFoldSelectInstruction(const Constant *Cond, + const Constant *V1, + const Constant *V2) { + if (Cond == ConstantBool::True) + return const_cast<Constant*>(V1); + else if (Cond == ConstantBool::False) + return const_cast<Constant*>(V2); + return 0; +} + + /// IdxCompare - Compare the two constants as though they were getelementptr /// indices. This allows coersion of the types to be the same thing. /// |