aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-03-31 02:56:11 +0000
committerChris Lattner <sabre@nondot.org>2004-03-31 02:56:11 +0000
commit4b2f08a3a91f3d0fa42f2df96c5a5814af065c39 (patch)
treecaa21b79ac5b72b4fc090dfbb5a3639b93d1965d
parent1e490ba4cd6c71dc9f45044fc4a10c6350a30d90 (diff)
Add support for constant expr casts
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12564 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/VMCore/Constants.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index f29f3157c8..6c6557dccd 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -571,6 +571,14 @@ void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV,
} else if (getOpcode() == Instruction::Cast) {
assert(getOperand(0) == From && "Cast only has one use!");
Replacement = ConstantExpr::getCast(To, getType());
+ } else if (getOpcode() == Instruction::Select) {
+ Constant *C1 = getOperand(0);
+ Constant *C2 = getOperand(1);
+ Constant *C3 = getOperand(2);
+ if (C1 == From) C1 = To;
+ if (C2 == From) C2 = To;
+ if (C3 == From) C3 = To;
+ Replacement = ConstantExpr::getSelect(C1, C2, C3);
} else if (getNumOperands() == 2) {
Constant *C1 = getOperand(0);
Constant *C2 = getOperand(1);