diff options
author | Serge Pavlov <sepavloff@gmail.com> | 2021-12-29 11:40:03 +0700 |
---|---|---|
committer | Serge Pavlov <sepavloff@gmail.com> | 2021-12-30 14:31:44 +0700 |
commit | ecfd9196d5dde5699d7fe3bd411949a56e01bd8c (patch) | |
tree | 0b17e3cc40e0a53fe4a3b8daf525dfd86407c219 /llvm/lib/IR/Constants.cpp | |
parent | 5da6d26896d196cfbc992af32f82f8d2faf100c5 (diff) | |
download | llvm-ecfd9196d5dde5699d7fe3bd411949a56e01bd8c.zip llvm-ecfd9196d5dde5699d7fe3bd411949a56e01bd8c.tar.gz llvm-ecfd9196d5dde5699d7fe3bd411949a56e01bd8c.tar.bz2 |
[ConstantFolding] Use ICmpInst::Predicate instead of plain integer
The function `ConstantFoldCompareInstruction` uses `unsigned short` to
represent compare predicate, although all usesrs of the respective
include file use definition of CmpInst also. This change replaces
predicate argument type in this function to `ICmpInst::Predicate`,
which allows to make code a bit clearer and simpler.
No functional changes.
Differential Revision: https://reviews.llvm.org/D116379
Diffstat (limited to 'llvm/lib/IR/Constants.cpp')
-rw-r--r-- | llvm/lib/IR/Constants.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 837be91..e753fc7 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -2546,11 +2546,11 @@ Constant *ConstantExpr::getGetElementPtr(Type *Ty, Constant *C, Constant *ConstantExpr::getICmp(unsigned short pred, Constant *LHS, Constant *RHS, bool OnlyIfReduced) { + auto Predicate = static_cast<CmpInst::Predicate>(pred); assert(LHS->getType() == RHS->getType()); - assert(CmpInst::isIntPredicate((CmpInst::Predicate)pred) && - "Invalid ICmp Predicate"); + assert(CmpInst::isIntPredicate(Predicate) && "Invalid ICmp Predicate"); - if (Constant *FC = ConstantFoldCompareInstruction(pred, LHS, RHS)) + if (Constant *FC = ConstantFoldCompareInstruction(Predicate, LHS, RHS)) return FC; // Fold a few common cases... if (OnlyIfReduced) @@ -2559,7 +2559,7 @@ Constant *ConstantExpr::getICmp(unsigned short pred, Constant *LHS, // Look up the constant in the table first to ensure uniqueness Constant *ArgVec[] = { LHS, RHS }; // Get the key type with both the opcode and predicate - const ConstantExprKeyType Key(Instruction::ICmp, ArgVec, pred); + const ConstantExprKeyType Key(Instruction::ICmp, ArgVec, Predicate); Type *ResultTy = Type::getInt1Ty(LHS->getContext()); if (VectorType *VT = dyn_cast<VectorType>(LHS->getType())) @@ -2571,11 +2571,11 @@ Constant *ConstantExpr::getICmp(unsigned short pred, Constant *LHS, Constant *ConstantExpr::getFCmp(unsigned short pred, Constant *LHS, Constant *RHS, bool OnlyIfReduced) { + auto Predicate = static_cast<CmpInst::Predicate>(pred); assert(LHS->getType() == RHS->getType()); - assert(CmpInst::isFPPredicate((CmpInst::Predicate)pred) && - "Invalid FCmp Predicate"); + assert(CmpInst::isFPPredicate(Predicate) && "Invalid FCmp Predicate"); - if (Constant *FC = ConstantFoldCompareInstruction(pred, LHS, RHS)) + if (Constant *FC = ConstantFoldCompareInstruction(Predicate, LHS, RHS)) return FC; // Fold a few common cases... if (OnlyIfReduced) @@ -2584,7 +2584,7 @@ Constant *ConstantExpr::getFCmp(unsigned short pred, Constant *LHS, // Look up the constant in the table first to ensure uniqueness Constant *ArgVec[] = { LHS, RHS }; // Get the key type with both the opcode and predicate - const ConstantExprKeyType Key(Instruction::FCmp, ArgVec, pred); + const ConstantExprKeyType Key(Instruction::FCmp, ArgVec, Predicate); Type *ResultTy = Type::getInt1Ty(LHS->getContext()); if (VectorType *VT = dyn_cast<VectorType>(LHS->getType())) |