[IR] Use CmpInst::isFPPredicate/isIntPredicate in a few other places. NFC

llvm-svn: 307224
This commit is contained in:
Craig Topper 2017-07-05 23:35:46 +00:00
parent 2a42d26579
commit 5bcc147909
2 changed files with 6 additions and 7 deletions

View File

@ -1914,8 +1914,8 @@ Constant *ConstantExpr::getGetElementPtr(Type *Ty, Constant *C,
Constant *ConstantExpr::getICmp(unsigned short pred, Constant *LHS, Constant *ConstantExpr::getICmp(unsigned short pred, Constant *LHS,
Constant *RHS, bool OnlyIfReduced) { Constant *RHS, bool OnlyIfReduced) {
assert(LHS->getType() == RHS->getType()); assert(LHS->getType() == RHS->getType());
assert(pred >= ICmpInst::FIRST_ICMP_PREDICATE && assert(CmpInst::isIntPredicate((CmpInst::Predicate)pred) &&
pred <= ICmpInst::LAST_ICMP_PREDICATE && "Invalid ICmp Predicate"); "Invalid ICmp Predicate");
if (Constant *FC = ConstantFoldCompareInstruction(pred, LHS, RHS)) if (Constant *FC = ConstantFoldCompareInstruction(pred, LHS, RHS))
return FC; // Fold a few common cases... return FC; // Fold a few common cases...
@ -1939,7 +1939,8 @@ Constant *ConstantExpr::getICmp(unsigned short pred, Constant *LHS,
Constant *ConstantExpr::getFCmp(unsigned short pred, Constant *LHS, Constant *ConstantExpr::getFCmp(unsigned short pred, Constant *LHS,
Constant *RHS, bool OnlyIfReduced) { Constant *RHS, bool OnlyIfReduced) {
assert(LHS->getType() == RHS->getType()); assert(LHS->getType() == RHS->getType());
assert(pred <= FCmpInst::LAST_FCMP_PREDICATE && "Invalid FCmp Predicate"); assert(CmpInst::isFPPredicate((CmpInst::Predicate)pred) &&
"Invalid FCmp Predicate");
if (Constant *FC = ConstantFoldCompareInstruction(pred, LHS, RHS)) if (Constant *FC = ConstantFoldCompareInstruction(pred, LHS, RHS))
return FC; // Fold a few common cases... return FC; // Fold a few common cases...

View File

@ -2955,8 +2955,7 @@ void Verifier::visitICmpInst(ICmpInst &IC) {
Assert(Op0Ty->isIntOrIntVectorTy() || Op0Ty->getScalarType()->isPointerTy(), Assert(Op0Ty->isIntOrIntVectorTy() || Op0Ty->getScalarType()->isPointerTy(),
"Invalid operand types for ICmp instruction", &IC); "Invalid operand types for ICmp instruction", &IC);
// Check that the predicate is valid. // Check that the predicate is valid.
Assert(IC.getPredicate() >= CmpInst::FIRST_ICMP_PREDICATE && Assert(IC.isIntPredicate(),
IC.getPredicate() <= CmpInst::LAST_ICMP_PREDICATE,
"Invalid predicate in ICmp instruction!", &IC); "Invalid predicate in ICmp instruction!", &IC);
visitInstruction(IC); visitInstruction(IC);
@ -2972,8 +2971,7 @@ void Verifier::visitFCmpInst(FCmpInst &FC) {
Assert(Op0Ty->isFPOrFPVectorTy(), Assert(Op0Ty->isFPOrFPVectorTy(),
"Invalid operand types for FCmp instruction", &FC); "Invalid operand types for FCmp instruction", &FC);
// Check that the predicate is valid. // Check that the predicate is valid.
Assert(FC.getPredicate() >= CmpInst::FIRST_FCMP_PREDICATE && Assert(FC.isFPPredicate(),
FC.getPredicate() <= CmpInst::LAST_FCMP_PREDICATE,
"Invalid predicate in FCmp instruction!", &FC); "Invalid predicate in FCmp instruction!", &FC);
visitInstruction(FC); visitInstruction(FC);