Fix bug: InstCombine/2003-06-22-ConstantExprCrash.ll
authorChris Lattner <sabre@nondot.org>
Sun, 22 Jun 2003 20:48:30 +0000 (20:48 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 22 Jun 2003 20:48:30 +0000 (20:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6857 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Constants.cpp

index afe494e9bbf9ecc1b0dadc9491fced1bbbc00e4d..935c2938c22ecb521cf3f5a4f3bf50518f48b6b6 100644 (file)
@@ -243,8 +243,14 @@ ConstantExpr::ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty)
   Operands.push_back(Use(C, this));
 }
 
+static bool isSetCC(unsigned Opcode) {
+  return Opcode == Instruction::SetEQ || Opcode == Instruction::SetNE ||
+         Opcode == Instruction::SetLT || Opcode == Instruction::SetGT ||
+         Opcode == Instruction::SetLE || Opcode == Instruction::SetGE;
+}
+
 ConstantExpr::ConstantExpr(unsigned Opcode, Constant *C1, Constant *C2)
-  : Constant(C1->getType()), iType(Opcode) {
+  : Constant(isSetCC(Opcode) ? Type::BoolTy : C1->getType()), iType(Opcode) {
   Operands.push_back(Use(C1, this));
   Operands.push_back(Use(C2, this));
 }