From: Chris Lattner Date: Fri, 12 Mar 2004 05:53:32 +0000 (+0000) Subject: Teach the constant folder how to do select instructions X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e97148628f8a52fff1752937f6f49945bbe9937b;p=oota-llvm.git 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 --- diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 5f7e0ef1b81..db21bd3d782 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(V1); + else if (Cond == ConstantBool::False) + return const_cast(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. ///