aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-08-04 18:50:09 +0000
committerChris Lattner <sabre@nondot.org>2004-08-04 18:50:09 +0000
commitc3d12f082397ec069cad1466967cef37c2fef185 (patch)
tree883bdccf50e4fa08d6989ca5d5a17b241506286b /lib/VMCore
parentff4c183790ab241b85170fdfc326a5d6959139ae (diff)
downloadexternal_llvm-c3d12f082397ec069cad1466967cef37c2fef185.zip
external_llvm-c3d12f082397ec069cad1466967cef37c2fef185.tar.gz
external_llvm-c3d12f082397ec069cad1466967cef37c2fef185.tar.bz2
Fix a latent bug exposed by my recent changes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15498 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Constants.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index f679f23..b65758b 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -1109,7 +1109,8 @@ Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode,
assert(C1->getType() == C2->getType() &&
"Operand types in binary constant expression should match");
- if (ReqTy == C1->getType())
+ if (ReqTy == C1->getType() || (Instruction::isRelational(Opcode) &&
+ ReqTy == Type::BoolTy))
if (Constant *FC = ConstantFoldBinaryInstruction(Opcode, C1, C2))
return FC; // Fold a few common cases...
@@ -1118,6 +1119,13 @@ Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode,
return ExprConstants.getOrCreate(ReqTy, Key);
}
+Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) {
+ if (Instruction::isRelational(Opcode))
+ return getTy(Type::BoolTy, Opcode, C1, C2);
+ else
+ return getTy(C1->getType(), Opcode, C1, C2);
+}
+
Constant *ConstantExpr::getSelectTy(const Type *ReqTy, Constant *C,
Constant *V1, Constant *V2) {
assert(C->getType() == Type::BoolTy && "Select condition must be bool!");