From c2a7d097f940f5265a8a56f98103030984dfa769 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Fri, 12 Jan 2007 00:02:12 +0000 Subject: [PATCH] Clean up logic after ConstantBool removal. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33096 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/PredicateSimplifier.cpp | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/lib/Transforms/Scalar/PredicateSimplifier.cpp b/lib/Transforms/Scalar/PredicateSimplifier.cpp index c577409f9a4..8defb871b76 100644 --- a/lib/Transforms/Scalar/PredicateSimplifier.cpp +++ b/lib/Transforms/Scalar/PredicateSimplifier.cpp @@ -432,11 +432,8 @@ namespace { NodeMap.insert(std::lower_bound(NodeMap.begin(), NodeMap.end(), MapEntry), MapEntry); -#if 1 - // This is the missing piece to turn on VRP. if (Constant *C = dyn_cast(V)) initializeConstant(C, MapEntry.index); -#endif return MapEntry.index; } @@ -1127,14 +1124,12 @@ namespace { Value *RHS = Op1; if (!isa(LHS)) std::swap(LHS, RHS); - ConstantInt *CB, *A; - if ((CB = dyn_cast(Canonical)) && - CB->getType() == Type::Int1Ty) { - if ((A = dyn_cast(LHS)) && - A->getType() == Type::Int1Ty) - add(RHS, ConstantInt::get(A->getBoolValue() ^ - CB->getBoolValue()), - ICmpInst::ICMP_EQ, NewContext); + if (ConstantInt *CI = dyn_cast(Canonical)) { + if (ConstantInt *Arg = dyn_cast(LHS)) { + add(RHS, ConstantInt::get(CI->getType(), CI->getZExtValue() ^ + Arg->getZExtValue()), + ICmpInst::ICMP_EQ, NewContext); + } } if (Canonical == LHS) { if (isa(Canonical)) @@ -1238,21 +1233,18 @@ namespace { case Instruction::Or: case Instruction::Add: case Instruction::Sub: - add(Unknown, Constant::getNullValue(Ty), ICmpInst::ICMP_EQ, NewContext); + add(Unknown, Constant::getNullValue(Ty), ICmpInst::ICMP_EQ, + NewContext); break; case Instruction::UDiv: case Instruction::SDiv: if (Unknown == Op0) break; // otherwise, fallthrough case Instruction::And: case Instruction::Mul: - Constant *One = NULL; - if (isa(Unknown)) - One = ConstantInt::get(Ty, 1); - else if (isa(Unknown) && - Unknown->getType() == Type::Int1Ty) - One = ConstantInt::getTrue(); - - if (One) add(Unknown, One, ICmpInst::ICMP_EQ, NewContext); + if (isa(Unknown)) { + Constant *One = ConstantInt::get(Ty, 1); + add(Unknown, One, ICmpInst::ICMP_EQ, NewContext); + } break; } } @@ -1274,6 +1266,8 @@ namespace { add(IC, ConstantInt::getFalse(), ICmpInst::ICMP_EQ, NewContext); } + // TODO: "bool %x s %y" implies %x = true and %y = false. + // TODO: make the predicate more strict, if possible. } else if (SelectInst *SI = dyn_cast(I)) {