OSDN Git Service

[IR] Use Instruction::isBinaryOp helper instead of raw enum range tests. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 22 Jun 2018 10:48:02 +0000 (10:48 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 22 Jun 2018 10:48:02 +0000 (10:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335335 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/ConstantRange.cpp
lib/IR/Constants.cpp

index bd65aed..157473f 100644 (file)
@@ -191,8 +191,7 @@ ConstantRange::makeGuaranteedNoWrapRegion(Instruction::BinaryOps BinOp,
     return CR0.inverse().unionWith(CR1.inverse()).inverse();
   };
 
-  assert(BinOp >= Instruction::BinaryOpsBegin &&
-         BinOp < Instruction::BinaryOpsEnd && "Binary operators only!");
+  assert(Instruction::isBinaryOp(BinOp) && "Binary operators only!");
 
   assert((NoWrapKind == OBO::NoSignedWrap ||
           NoWrapKind == OBO::NoUnsignedWrap ||
@@ -665,8 +664,7 @@ ConstantRange ConstantRange::sextOrTrunc(uint32_t DstTySize) const {
 
 ConstantRange ConstantRange::binaryOp(Instruction::BinaryOps BinOp,
                                       const ConstantRange &Other) const {
-  assert(BinOp >= Instruction::BinaryOpsBegin &&
-         BinOp < Instruction::BinaryOpsEnd && "Binary operators only!");
+  assert(Instruction::isBinaryOp(BinOp) && "Binary operators only!");
 
   switch (BinOp) {
   case Instruction::Add:
index e775275..5ec0834 100644 (file)
@@ -1773,8 +1773,7 @@ Constant *ConstantExpr::getAddrSpaceCast(Constant *C, Type *DstTy,
 Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2,
                             unsigned Flags, Type *OnlyIfReducedTy) {
   // Check the operands for consistency first.
-  assert(Opcode >= Instruction::BinaryOpsBegin &&
-         Opcode <  Instruction::BinaryOpsEnd   &&
+  assert(Instruction::isBinaryOp(Opcode) &&
          "Invalid opcode in binary constant expression");
   assert(C1->getType() == C2->getType() &&
          "Operand types in binary constant expression should match");